ShiftJIS-X0213-MapUTF
view release on metacpan or search on metacpan
"sjis0213_to_utf16be",
"sjis0213_to_utf32le",
"sjis0213_to_utf32be",
};
static char* funcname_fm[2 * NUM_fromUTF] = {
"unicode_to_sjis2004",
"utf8_to_sjis2004",
"utf16le_to_sjis2004",
"utf16be_to_sjis2004",
"utf32le_to_sjis2004",
"utf32be_to_sjis2004",
"utf16_to_sjis2004",
"utf32_to_sjis2004",
"unicode_to_sjis0213",
"utf8_to_sjis0213",
"utf16le_to_sjis0213",
"utf16be_to_sjis0213",
"utf32le_to_sjis0213",
"utf32be_to_sjis0213",
"utf16_to_sjis0213",
"utf32_to_sjis0213",
};
static STRLEN maxlen_to[NUM_toUTF] = {
MaxLenToUni,
MaxLenToU8,
MaxLenToU16,
MaxLenToU16,
MaxLenToU32,
MaxLenToU32,
};
static STRLEN maxlen_fm[NUM_fromUTF] = {
MaxLenFmUni,
MaxLenFmU8,
MaxLenFmU16,
MaxLenFmU16,
MaxLenFmU32,
MaxLenFmU32,
MaxLenFmU16,
MaxLenFmU32,
};
static U8* (*app_uv_in[NUM_toUTF])(U8*, UV) = {
NULL,
app_in_utf8,
app_in_utf16le,
app_in_utf16be,
app_in_utf32le,
app_in_utf32be,
};
static UV (*ord_uv_in[NUM_fromUTF])(U8 *, STRLEN, STRLEN *) = {
NULL,
ord_in_utf8,
ord_in_utf16le,
ord_in_utf16be,
ord_in_utf32le,
ord_in_utf32be,
ord_in_utf16be, /* w/o BOM*/
ord_in_utf32be, /* w/o BOM*/
};
MODULE = ShiftJIS::X0213::MapUTF PACKAGE = ShiftJIS::X0213::MapUTF
PROTOTYPES: DISABLE
void
sjis2004_to_unicode (...)
ALIAS:
sjis2004_to_utf8 = 1
sjis2004_to_utf16le = 2
sjis2004_to_utf16be = 3
sjis2004_to_utf32le = 4
sjis2004_to_utf32be = 5
sjis0213_to_unicode = 6
sjis0213_to_utf8 = 7
sjis0213_to_utf16le = 8
sjis0213_to_utf16be = 9
sjis0213_to_utf32le = 10
sjis0213_to_utf32be = 11
PREINIT:
SV *src, *dst, *cvref;
STRLEN srclen, dstlen, mblen, ulen;
U8 *s, *e, *p, *d, uni[UTF8_MAXLEN + 1];
UV uv, u_temp;
struct leading lb;
U8* (*app_uv)(U8*, UV);
int id_utf, use2004;
PPCODE:
use2004 = ix < NUM_toUTF;
id_utf = ix % NUM_toUTF;
STMT_ASSIGN_CVREF_AND_SRC(funcname_to[ix])
if (SvUTF8(src)) {
src = sv_mortalcopy(src);
sv_utf8_downgrade(src, 0);
}
STMT_ASSIGN_LENDST(maxlen_to[id_utf])
if (id_utf == 0)
SvUTF8_on(dst);
app_uv = app_uv_in[id_utf];
if (cvref) {
for (p = s; p < e; p += mblen) {
STMT_GET_MBLEN
if (!mblen) {
sv_cat_retcvref(dst, cvref, newSVuv((UV)*p), TRUE);
p++;
continue;
}
STMT_GET_UV_FROM_MB
if (uv || !*p) {
if (Is_VALID_UTF(uv)) {
ulen = id_utf ? app_uv(uni, uv) - uni
: uvuni_to_utf8(uni, uv) - uni;
sv_catpvn(dst, (char*)uni, ulen);
}
else {
( run in 0.586 second using v1.01-cache-2.11-cpan-39bf76dae61 )