53 while (
len > 0 && *from)
74 if (*s < 0x20 || *s == 0x7f)
88 while (
len > 0 && *from)
90 if (*from ==
SS2 &&
len >= 2)
94 *to = (
SS2 << 8) | *from++;
97 else if (*from ==
SS3 &&
len >= 3)
100 *to = (
SS3 << 16) | (*from++ << 8);
215 while (
len > 0 && *from)
217 if (*from ==
SS2 &&
len >= 3)
220 *to = (
SS2 << 16) | (*from++ << 8);
224 else if (*from ==
SS3 &&
len >= 3)
227 *to = (
SS3 << 16) | (*from++ << 8);
282 while (
len > 0 && *from)
284 if (*from ==
SS2 &&
len >= 4)
287 *to = (((
uint32)
SS2) << 24) | (*from++ << 16);
292 else if (*from ==
SS3 &&
len >= 3)
295 *to = (
SS3 << 16) | (*from++ << 8);
360 while (
len > 0 && *from)
364 if ((
c = (*from >> 24)))
367 *to++ = (*from >> 16) & 0xff;
368 *to++ = (*from >> 8) & 0xff;
369 *to++ = *from & 0xff;
372 else if ((
c = (*from >> 16)))
375 *to++ = (*from >> 8) & 0xff;
376 *to++ = *from & 0xff;
379 else if ((
c = (*from >> 8)))
382 *to++ = *from & 0xff;
428 while (
len > 0 && *from)
430 if ((*from & 0x80) == 0)
435 else if ((*from & 0xe0) == 0xc0)
441 *to = (c1 << 6) | c2;
444 else if ((*from & 0xf0) == 0xe0)
451 *to = (c1 << 12) | (c2 << 6) | c3;
454 else if ((*from & 0xf8) == 0xf0)
462 *to = (c1 << 18) | (c2 << 12) | (c3 << 6) | c4;
492 utf8string[0] = 0xC0 | ((
c >> 6) & 0x1F);
493 utf8string[1] = 0x80 | (
c & 0x3F);
495 else if (
c <= 0xFFFF)
497 utf8string[0] = 0xE0 | ((
c >> 12) & 0x0F);
498 utf8string[1] = 0x80 | ((
c >> 6) & 0x3F);
499 utf8string[2] = 0x80 | (
c & 0x3F);
503 utf8string[0] = 0xF0 | ((
c >> 18) & 0x07);
504 utf8string[1] = 0x80 | ((
c >> 12) & 0x3F);
505 utf8string[2] = 0x80 | ((
c >> 6) & 0x3F);
506 utf8string[3] = 0x80 | (
c & 0x3F);
523 while (
len > 0 && *from)
554 if ((*s & 0x80) == 0)
556 else if ((*s & 0xe0) == 0xc0)
558 else if ((*s & 0xf0) == 0xe0)
560 else if ((*s & 0xf8) == 0xf0)
563 else if ((*s & 0xfc) == 0xf8)
565 else if ((*s & 0xfe) == 0xfc)
598 if (ucs < table[0].first || ucs > table[max].last)
602 mid = (min + max) / 2;
603 if (ucs > table[mid].last)
605 else if (ucs < table[mid].first)
649 if (ucs < 0x20 || (ucs >= 0x7f && ucs < 0xa0) || ucs > 0x0010ffff)
682 if ((*
c & 0x80) == 0)
684 else if ((*
c & 0xe0) == 0xc0)
685 return (
pg_wchar) (((
c[0] & 0x1f) << 6) |
687 else if ((*
c & 0xf0) == 0xe0)
688 return (
pg_wchar) (((
c[0] & 0x0f) << 12) |
689 ((
c[1] & 0x3f) << 6) |
691 else if ((*
c & 0xf8) == 0xf0)
692 return (
pg_wchar) (((
c[0] & 0x07) << 18) |
693 ((
c[1] & 0x3f) << 12) |
694 ((
c[2] & 0x3f) << 6) |
718 while (
len > 0 && *from)
750 *to = (
unsigned char) *from++;
771 while (
len > 0 && *from)
775 lb = (*from >> 16) & 0xff;
779 *to++ = *from & 0xff;
785 *to++ = (*from >> 8) & 0xff;
786 *to++ = *from & 0xff;
793 *to++ = *from & 0xff;
800 *to++ = *from & 0xff;
807 *to++ = (*from >> 8) & 0xff;
808 *to++ = *from & 0xff;
815 *to++ = (*from >> 8) & 0xff;
816 *to++ = *from & 0xff;
821 *to++ = *from & 0xff;
883 while (
len > 0 && *from)
905 while (
len > 0 && *from)
935 if (*s >= 0xa1 && *s <= 0xdf)
949 if (*s >= 0xa1 && *s <= 0xdf)
1061 else if (*(s + 1) >= 0x30 && *(s + 1) <= 0x39)
1111 const unsigned char *nullpos = memchr(s, 0,
len);
1113 if (nullpos == NULL)
1119 #define IS_EUC_RANGE_VALID(c) ((c) >= 0xa1 && (c) <= 0xfe)
1137 if (c2 < 0xa1 || c2 > 0xdf)
1179 const unsigned char *start = s;
1237 const unsigned char *start = s;
1264 #define pg_euccn_verifychar pg_euckr_verifychar
1265 #define pg_euccn_verifystr pg_euckr_verifystr
1283 if (c2 < 0xa1 || c2 > 0xa7)
1320 const unsigned char *start = s;
1373 const unsigned char *start = s;
1423 const unsigned char *start = s;
1458 const unsigned char *nullpos = memchr(s, 0,
len);
1460 if (nullpos == NULL)
1492 const unsigned char *start = s;
1541 const unsigned char *start = s;
1590 const unsigned char *start = s;
1639 const unsigned char *start = s;
1672 else if (
len >= 4 && *(s + 1) >= 0x30 && *(s + 1) <= 0x39)
1675 if (*s >= 0x81 && *s <= 0xfe &&
1676 *(s + 2) >= 0x81 && *(s + 2) <= 0xfe &&
1677 *(s + 3) >= 0x30 && *(s + 3) <= 0x39)
1682 else if (
len >= 2 && *s >= 0x81 && *s <= 0xfe)
1685 if ((*(s + 1) >= 0x40 && *(s + 1) <= 0x7e) ||
1686 (*(s + 1) >= 0x80 && *(s + 1) <= 0xfe))
1699 const unsigned char *start = s;
1730 if ((*s & 0x80) == 0)
1736 else if ((*s & 0xe0) == 0xc0)
1738 else if ((*s & 0xf0) == 0xe0)
1740 else if ((*s & 0xf8) == 0xf0)
1822 #define ASC (END << BGN)
1824 #define L2A (CS1 << BGN)
1826 #define L3A (P3A << BGN)
1827 #define L3B (CS2 << BGN)
1828 #define L3C (P3B << BGN)
1830 #define L4A (P4A << BGN)
1831 #define L4B (CS3 << BGN)
1832 #define L4C (P4B << BGN)
1834 #define CR1 (END << CS1) | (CS1 << CS2) | (CS2 << CS3) | (CS1 << P3B) | (CS2 << P4B)
1835 #define CR2 (END << CS1) | (CS1 << CS2) | (CS2 << CS3) | (CS1 << P3B) | (CS2 << P4A)
1836 #define CR3 (END << CS1) | (CS1 << CS2) | (CS2 << CS3) | (CS1 << P3A) | (CS2 << P4A)
1918 const unsigned char *start = s;
1919 const int orig_len =
len;
1927 #define STRIDE_LENGTH (2 * sizeof(Vector8))
2025 if (a < 0x80 || a > 0xBF)
2030 if (a < 0x80 || a > 0xBF)
2038 if (a < 0xA0 || a > 0xBF)
2042 if (a < 0x80 || a > 0x9F)
2046 if (a < 0x90 || a > 0xBF)
2050 if (a < 0x80 || a > 0x8F)
2054 if (a < 0x80 || a > 0xBF)
2061 if (
a >= 0x80 &&
a < 0xC2)
static bool is_valid_ascii(const unsigned char *s, int len)
#define IS_HIGHBIT_SET(ch)
Assert(fmt[strlen(fmt) - 1] !='\n')
static rewind_source * source
#define IS_LCPRV2_B_RANGE(c)
#define IS_LCPRV1_A_RANGE(c)
#define PG_VALID_ENCODING(_enc)
#define IS_LCPRV1_B_RANGE(c)
#define IS_LCPRV2_A_RANGE(c)
size_t strnlen(const char *str, size_t maxlen)
static const struct mbinterval east_asian_fw[]
static const struct mbinterval nonspacing[]
static int pg_uhc_verifystr(const unsigned char *s, int len)
static int pg_latin1_dsplen(const unsigned char *s)
int pg_encoding_mblen_bounded(int encoding, const char *mbstr)
static int pg_euctw_mblen(const unsigned char *s)
static int pg_euckr_dsplen(const unsigned char *s)
static const uint32 Utf8Transition[256]
bool pg_utf8_islegal(const unsigned char *source, int length)
static int pg_ascii_verifystr(const unsigned char *s, int len)
static int pg_latin1_verifychar(const unsigned char *s, int len)
static int pg_sjis_dsplen(const unsigned char *s)
static int pg_sjis_verifychar(const unsigned char *s, int len)
static int pg_euc2wchar_with_len(const unsigned char *from, pg_wchar *to, int len)
static int pg_eucjp_dsplen(const unsigned char *s)
static int pg_ascii2wchar_with_len(const unsigned char *from, pg_wchar *to, int len)
static int pg_uhc_verifychar(const unsigned char *s, int len)
static int pg_gbk_dsplen(const unsigned char *s)
static int pg_euckr2wchar_with_len(const unsigned char *from, pg_wchar *to, int len)
static int pg_euctw2wchar_with_len(const unsigned char *from, pg_wchar *to, int len)
#define pg_euccn_verifychar
static int pg_sjis_verifystr(const unsigned char *s, int len)
static int pg_johab_mblen(const unsigned char *s)
unsigned char * unicode_to_utf8(pg_wchar c, unsigned char *utf8string)
static int pg_johab_dsplen(const unsigned char *s)
static int pg_big5_verifystr(const unsigned char *s, int len)
static int pg_mule_verifychar(const unsigned char *s, int len)
static int pg_eucjp2wchar_with_len(const unsigned char *from, pg_wchar *to, int len)
static int pg_latin1_verifystr(const unsigned char *s, int len)
static int pg_latin1_mblen(const unsigned char *s)
static int pg_ascii_verifychar(const unsigned char *s, int len)
static int pg_ascii_mblen(const unsigned char *s)
static int mbbisearch(pg_wchar ucs, const struct mbinterval *table, int max)
static int pg_big5_dsplen(const unsigned char *s)
#define pg_euccn_verifystr
int pg_utf_mblen(const unsigned char *s)
static int pg_eucjp_mblen(const unsigned char *s)
static int pg_gbk_verifychar(const unsigned char *s, int len)
static int pg_big5_mblen(const unsigned char *s)
static int pg_euccn_dsplen(const unsigned char *s)
static int pg_euctw_verifychar(const unsigned char *s, int len)
static int pg_euckr_verifychar(const unsigned char *s, int len)
static int pg_euctw_verifystr(const unsigned char *s, int len)
static int pg_gbk_verifystr(const unsigned char *s, int len)
static int pg_gb18030_dsplen(const unsigned char *s)
static int pg_utf2wchar_with_len(const unsigned char *from, pg_wchar *to, int len)
int pg_mule_mblen(const unsigned char *s)
static int pg_euccn_mblen(const unsigned char *s)
static int pg_gbk_mblen(const unsigned char *s)
static int pg_eucjp_verifystr(const unsigned char *s, int len)
static int pg_johab_verifystr(const unsigned char *s, int len)
static int pg_euc_dsplen(const unsigned char *s)
static int pg_gb18030_verifystr(const unsigned char *s, int len)
static int pg_euckr_verifystr(const unsigned char *s, int len)
static int pg_wchar2mule_with_len(const pg_wchar *from, unsigned char *to, int len)
static int pg_sjis_mblen(const unsigned char *s)
#define IS_EUC_RANGE_VALID(c)
pg_wchar utf8_to_unicode(const unsigned char *c)
static int pg_uhc_dsplen(const unsigned char *s)
static int pg_eucjp_verifychar(const unsigned char *s, int len)
static int pg_big5_verifychar(const unsigned char *s, int len)
static int pg_gb18030_verifychar(const unsigned char *s, int len)
static int pg_mule_verifystr(const unsigned char *s, int len)
static int pg_wchar2euc_with_len(const pg_wchar *from, unsigned char *to, int len)
static int pg_utf8_verifychar(const unsigned char *s, int len)
static int pg_wchar2single_with_len(const pg_wchar *from, unsigned char *to, int len)
static int pg_wchar2utf_with_len(const pg_wchar *from, unsigned char *to, int len)
static int pg_euccn2wchar_with_len(const unsigned char *from, pg_wchar *to, int len)
static int pg_gb18030_mblen(const unsigned char *s)
int pg_encoding_dsplen(int encoding, const char *mbstr)
static void utf8_advance(const unsigned char *s, uint32 *state, int len)
static int pg_euctw_dsplen(const unsigned char *s)
static int pg_latin12wchar_with_len(const unsigned char *from, pg_wchar *to, int len)
static int pg_uhc_mblen(const unsigned char *s)
static int pg_euc_mblen(const unsigned char *s)
static int pg_mule_dsplen(const unsigned char *s)
int pg_encoding_verifymbstr(int encoding, const char *mbstr, int len)
static int pg_utf8_verifystr(const unsigned char *s, int len)
static int pg_euckr_mblen(const unsigned char *s)
const pg_wchar_tbl pg_wchar_table[]
static int pg_mule2wchar_with_len(const unsigned char *from, pg_wchar *to, int len)
int pg_encoding_max_length(int encoding)
int pg_encoding_mblen(int encoding, const char *mbstr)
static int pg_johab_verifychar(const unsigned char *s, int len)
static int pg_ascii_dsplen(const unsigned char *s)
int pg_encoding_verifymbchar(int encoding, const char *mbstr, int len)
static int ucs_wcwidth(pg_wchar ucs)
static int pg_utf_dsplen(const unsigned char *s)