1 #include "EXTERN.h"
2 #include "perl.h"
3 #include "XSUB.h"
4
5 static int
not_here(s)6 not_here(s)
7 char *s;
8 {
9 croak("%s not implemented on this architecture", s);
10 return -1;
11 }
12
13 #define PERL_XS 1
14 #include "uni.c"
15
16 MODULE = Jcode::Unicode PACKAGE = Jcode::Unicode
17
18 PROTOTYPES: ENABLE
19
20 char *
21 euc_ucs2(src)
22 SV * src
23 PROTOTYPE: $;$
24 CODE:
25 STRLEN srclen;
26 STRLEN dstlen;
27 char *s = SvROK(src) ? SvPV(SvRV(src), srclen) :SvPV(src, srclen);
28 dstlen = srclen * 3 + 10; /* large enough? */
29 ST(0) = sv_2mortal(newSV(dstlen));
30 dstlen = _euc_ucs2((unsigned char *)SvPVX(ST(0)), (unsigned char *)s);
31 SvCUR_set(ST(0), dstlen);
32 SvPOK_only(ST(0));
33 if (SvROK(src)) { sv_setsv(SvRV(src), ST(0)); }
34
35 char *
36 ucs2_euc(src)
37 SV * src
38 PROTOTYPE: $;$
39 CODE:
40 STRLEN srclen;
41 STRLEN dstlen;
42 char *s = SvROK(src) ? SvPV(SvRV(src), srclen) :SvPV(src, srclen);
43 dstlen = srclen * 3 + 10; /* large enough? */
44 ST(0) = sv_2mortal(newSV(dstlen));
45 dstlen = _ucs2_euc((unsigned char *)SvPVX(ST(0)), (unsigned char *)s, srclen);
46 SvCUR_set(ST(0), dstlen);
47 SvPOK_only(ST(0));
48 if (SvROK(src)) { sv_setsv(SvRV(src), ST(0)); }
49
50 char *
51 utf8_ucs2(src)
52 SV * src
53 PROTOTYPE: $
54 CODE:
55 STRLEN srclen;
56 STRLEN dstlen;
57 char *s = SvROK(src) ? SvPV(SvRV(src), srclen) :SvPV(src, srclen);
58 dstlen = srclen * 3 + 10; /* large enough? */
59 ST(0) = sv_2mortal(newSV(dstlen));
60 dstlen = _utf8_ucs2((unsigned char *)SvPVX(ST(0)), (unsigned char *)s);
61 SvCUR_set(ST(0), dstlen);
62 SvPOK_only(ST(0));
63 if (SvROK(src)) { sv_setsv(SvRV(src), ST(0)); }
64
65 char *
66 ucs2_utf8(src)
67 SV * src
68 PROTOTYPE: $
69 CODE:
70 STRLEN srclen;
71 STRLEN dstlen;
72 char *s = SvROK(src) ? SvPV(SvRV(src), srclen) :SvPV(src, srclen);
73 dstlen = srclen * 3 + 10; /* large enough? */
74 ST(0) = sv_2mortal(newSV(dstlen));
75 dstlen = _ucs2_utf8((unsigned char *)SvPVX(ST(0)), (unsigned char *)s, srclen);
76 SvCUR_set(ST(0), dstlen);
77 SvPOK_only(ST(0));
78 if (SvROK(src)) { sv_setsv(SvRV(src), ST(0)); }
79
80 char *
81 utf8_euc(src)
82 SV * src
83 PROTOTYPE: $
84 CODE:
85 STRLEN srclen;
86 STRLEN dstlen;
87 char *s = SvROK(src) ? SvPV(SvRV(src), srclen) :SvPV(src, srclen);
88 dstlen = srclen * 3 + 10; /* large enough? */
89 ST(0) = sv_2mortal(newSV(dstlen));
90 dstlen = _utf8_euc((unsigned char *)SvPVX(ST(0)), (unsigned char *)s);
91 SvCUR_set(ST(0), dstlen);
92 SvPOK_only(ST(0));
93 if (SvROK(src)) { sv_setsv(SvRV(src), ST(0)); }
94
95 char *
96 euc_utf8(src)
97 SV * src
98 PROTOTYPE: $
99 CODE:
100 STRLEN srclen;
101 STRLEN dstlen;
102 char *s = SvROK(src) ? SvPV(SvRV(src), srclen) :SvPV(src, srclen);
103 dstlen = srclen * 3 + 10; /* large enough? */
104 ST(0) = sv_2mortal(newSV(dstlen));
105 dstlen = _euc_utf8((unsigned char *)SvPVX(ST(0)), (unsigned char *)s);
106 SvCUR_set(ST(0), dstlen);
107 SvPOK_only(ST(0));
108 if (SvROK(src)) { sv_setsv(SvRV(src), ST(0)); }
109
110
111
112
113