File: Unicode.xs

package info (click to toggle)
libjcode-pm-perl 2.07-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,440 kB
  • sloc: perl: 14,814; ansic: 11,032; makefile: 3
file content (112 lines) | stat: -rw-r--r-- 3,189 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"

static int
not_here(s)
char *s;
{
    croak("%s not implemented on this architecture", s);
    return -1;
}

#define PERL_XS 1
#include "uni.c"

MODULE = Jcode::Unicode	PACKAGE = Jcode::Unicode

PROTOTYPES: ENABLE

char *
euc_ucs2(src)
        SV *            src
    PROTOTYPE: $;$
    CODE:
        STRLEN srclen;
        STRLEN dstlen;
        char *s = SvROK(src) ? SvPV(SvRV(src), srclen) :SvPV(src, srclen);
        dstlen = srclen * 3 + 10; /* large enough? */
	ST(0) = sv_2mortal(newSV(dstlen));
	dstlen = _euc_ucs2((unsigned char *)SvPVX(ST(0)), (unsigned char *)s);
        SvCUR_set(ST(0), dstlen);
        SvPOK_only(ST(0));
	if (SvROK(src)) { sv_setsv(SvRV(src), ST(0)); }

char *
ucs2_euc(src)
        SV *            src
    PROTOTYPE: $;$
    CODE:
        STRLEN srclen;
        STRLEN dstlen;
        char *s = SvROK(src) ? SvPV(SvRV(src), srclen) :SvPV(src, srclen);
        dstlen = srclen * 3 + 10; /* large enough? */
        ST(0) = sv_2mortal(newSV(dstlen));
        dstlen = _ucs2_euc((unsigned char *)SvPVX(ST(0)), (unsigned char *)s, srclen);
        SvCUR_set(ST(0), dstlen);
        SvPOK_only(ST(0));
	if (SvROK(src)) { sv_setsv(SvRV(src), ST(0)); }

char *
utf8_ucs2(src)
        SV *            src
    PROTOTYPE: $
    CODE:
        STRLEN srclen;
        STRLEN dstlen;
        char *s = SvROK(src) ? SvPV(SvRV(src), srclen) :SvPV(src, srclen);
        dstlen = srclen * 3 + 10; /* large enough? */
        ST(0) = sv_2mortal(newSV(dstlen));
        dstlen = _utf8_ucs2((unsigned char *)SvPVX(ST(0)), (unsigned char *)s);
        SvCUR_set(ST(0), dstlen);
        SvPOK_only(ST(0));
	if (SvROK(src)) { sv_setsv(SvRV(src), ST(0)); }

char *
ucs2_utf8(src)
        SV *            src
    PROTOTYPE: $
    CODE:
        STRLEN srclen;
        STRLEN dstlen;
        char *s = SvROK(src) ? SvPV(SvRV(src), srclen) :SvPV(src, srclen);
        dstlen = srclen * 3 + 10; /* large enough? */
        ST(0) = sv_2mortal(newSV(dstlen));
        dstlen = _ucs2_utf8((unsigned char *)SvPVX(ST(0)), (unsigned char *)s, srclen);
        SvCUR_set(ST(0), dstlen);
        SvPOK_only(ST(0));
	if (SvROK(src)) { sv_setsv(SvRV(src), ST(0)); }

char *
utf8_euc(src)
        SV *            src
    PROTOTYPE: $
    CODE:
        STRLEN srclen;
        STRLEN dstlen;
        char *s = SvROK(src) ? SvPV(SvRV(src), srclen) :SvPV(src, srclen);
        dstlen = srclen * 3 + 10; /* large enough? */
        ST(0) = sv_2mortal(newSV(dstlen));
        dstlen = _utf8_euc((unsigned char *)SvPVX(ST(0)), (unsigned char *)s);
        SvCUR_set(ST(0), dstlen);
        SvPOK_only(ST(0));
	if (SvROK(src)) { sv_setsv(SvRV(src), ST(0)); }

char *
euc_utf8(src)
        SV *            src
    PROTOTYPE: $
    CODE:
        STRLEN srclen;
        STRLEN dstlen;
        char *s = SvROK(src) ? SvPV(SvRV(src), srclen) :SvPV(src, srclen);
        dstlen = srclen * 3 + 10; /* large enough? */
        ST(0) = sv_2mortal(newSV(dstlen));
        dstlen = _euc_utf8((unsigned char *)SvPVX(ST(0)), (unsigned char *)s);
        SvCUR_set(ST(0), dstlen);
        SvPOK_only(ST(0));
	if (SvROK(src)) { sv_setsv(SvRV(src), ST(0)); }