PostgreSQL Source Code git master
Loading...
Searching...
No Matches
wchar.c File Reference
#include "c.h"
#include <limits.h>
#include "mb/pg_wchar.h"
#include "utils/ascii.h"
#include "common/unicode_nonspacing_table.h"
#include "common/unicode_east_asian_fw_table.h"
Include dependency graph for wchar.c:

Go to the source code of this file.

Data Structures

struct  mbinterval
 

Macros

#define NONUTF8_INVALID_BYTE0   (0x8d)
 
#define NONUTF8_INVALID_BYTE1   (' ')
 
#define MB2CHAR_NEED_AT_LEAST(len, need)   if ((len) < (need)) break
 
#define IS_EUC_RANGE_VALID(c)   ((c) >= 0xa1 && (c) <= 0xfe)
 
#define pg_euccn_verifychar   pg_euckr_verifychar
 
#define pg_euccn_verifystr   pg_euckr_verifystr
 
#define ERR   0
 
#define BGN   11
 
#define CS1   16
 
#define CS2   1
 
#define CS3   5
 
#define P3A   6 /* Lead was E0, check for 3-byte overlong */
 
#define P3B   20 /* Lead was ED, check for surrogate */
 
#define P4A   25 /* Lead was F0, check for 4-byte overlong */
 
#define P4B   30 /* Lead was F4, check for too-large */
 
#define END   BGN
 
#define ASC   (END << BGN)
 
#define L2A   (CS1 << BGN)
 
#define L3A   (P3A << BGN)
 
#define L3B   (CS2 << BGN)
 
#define L3C   (P3B << BGN)
 
#define L4A   (P4A << BGN)
 
#define L4B   (CS3 << BGN)
 
#define L4C   (P4B << BGN)
 
#define CR1   (END << CS1) | (CS1 << CS2) | (CS2 << CS3) | (CS1 << P3B) | (CS2 << P4B)
 
#define CR2   (END << CS1) | (CS1 << CS2) | (CS2 << CS3) | (CS1 << P3B) | (CS2 << P4A)
 
#define CR3   (END << CS1) | (CS1 << CS2) | (CS2 << CS3) | (CS1 << P3A) | (CS2 << P4A)
 
#define ILL   ERR
 
#define STRIDE_LENGTH   (2 * sizeof(Vector8))
 

Functions

static int pg_ascii2wchar_with_len (const unsigned char *from, pg_wchar *to, int len)
 
static int pg_ascii_mblen (const unsigned char *s)
 
static int pg_ascii_dsplen (const unsigned char *s)
 
static int pg_euc2wchar_with_len (const unsigned char *from, pg_wchar *to, int len)
 
static int pg_euc_mblen (const unsigned char *s)
 
static int pg_euc_dsplen (const unsigned char *s)
 
static int pg_eucjp2wchar_with_len (const unsigned char *from, pg_wchar *to, int len)
 
static int pg_eucjp_mblen (const unsigned char *s)
 
static int pg_eucjp_dsplen (const unsigned char *s)
 
static int pg_euckr2wchar_with_len (const unsigned char *from, pg_wchar *to, int len)
 
static int pg_euckr_mblen (const unsigned char *s)
 
static int pg_euckr_dsplen (const unsigned char *s)
 
static int pg_euccn2wchar_with_len (const unsigned char *from, pg_wchar *to, int len)
 
static int pg_euccn_mblen (const unsigned char *s)
 
static int pg_euccn_dsplen (const unsigned char *s)
 
static int pg_euctw2wchar_with_len (const unsigned char *from, pg_wchar *to, int len)
 
static int pg_euctw_mblen (const unsigned char *s)
 
static int pg_euctw_dsplen (const unsigned char *s)
 
static int pg_wchar2euc_with_len (const pg_wchar *from, unsigned char *to, int len)
 
static int pg_johab_mblen (const unsigned char *s)
 
static int pg_johab_dsplen (const unsigned char *s)
 
static int pg_utf2wchar_with_len (const unsigned char *from, pg_wchar *to, int len)
 
static int pg_wchar2utf_with_len (const pg_wchar *from, unsigned char *to, int len)
 
int pg_utf_mblen (const unsigned char *s)
 
static int mbbisearch (pg_wchar ucs, const struct mbinterval *table, int max)
 
static int ucs_wcwidth (pg_wchar ucs)
 
static int pg_utf_dsplen (const unsigned char *s)
 
static int pg_latin12wchar_with_len (const unsigned char *from, pg_wchar *to, int len)
 
static int pg_wchar2single_with_len (const pg_wchar *from, unsigned char *to, int len)
 
static int pg_latin1_mblen (const unsigned char *s)
 
static int pg_latin1_dsplen (const unsigned char *s)
 
static int pg_sjis_mblen (const unsigned char *s)
 
static int pg_sjis_dsplen (const unsigned char *s)
 
static int pg_big5_mblen (const unsigned char *s)
 
static int pg_big5_dsplen (const unsigned char *s)
 
static int pg_gbk_mblen (const unsigned char *s)
 
static int pg_gbk_dsplen (const unsigned char *s)
 
static int pg_uhc_mblen (const unsigned char *s)
 
static int pg_uhc_dsplen (const unsigned char *s)
 
static int pg_gb18030_mblen (const unsigned char *s)
 
static int pg_gb18030_dsplen (const unsigned char *s)
 
static int pg_ascii_verifychar (const unsigned char *s, int len)
 
static int pg_ascii_verifystr (const unsigned char *s, int len)
 
static int pg_eucjp_verifychar (const unsigned char *s, int len)
 
static int pg_eucjp_verifystr (const unsigned char *s, int len)
 
static int pg_euckr_verifychar (const unsigned char *s, int len)
 
static int pg_euckr_verifystr (const unsigned char *s, int len)
 
static int pg_euctw_verifychar (const unsigned char *s, int len)
 
static int pg_euctw_verifystr (const unsigned char *s, int len)
 
static int pg_johab_verifychar (const unsigned char *s, int len)
 
static int pg_johab_verifystr (const unsigned char *s, int len)
 
static int pg_latin1_verifychar (const unsigned char *s, int len)
 
static int pg_latin1_verifystr (const unsigned char *s, int len)
 
static int pg_sjis_verifychar (const unsigned char *s, int len)
 
static int pg_sjis_verifystr (const unsigned char *s, int len)
 
static int pg_big5_verifychar (const unsigned char *s, int len)
 
static int pg_big5_verifystr (const unsigned char *s, int len)
 
static int pg_gbk_verifychar (const unsigned char *s, int len)
 
static int pg_gbk_verifystr (const unsigned char *s, int len)
 
static int pg_uhc_verifychar (const unsigned char *s, int len)
 
static int pg_uhc_verifystr (const unsigned char *s, int len)
 
static int pg_gb18030_verifychar (const unsigned char *s, int len)
 
static int pg_gb18030_verifystr (const unsigned char *s, int len)
 
static int pg_utf8_verifychar (const unsigned char *s, int len)
 
static void utf8_advance (const unsigned char *s, uint32 *state, int len)
 
static int pg_utf8_verifystr (const unsigned char *s, int len)
 
bool pg_utf8_islegal (const unsigned char *source, int length)
 
void pg_encoding_set_invalid (int encoding, char *dst)
 
int pg_encoding_mblen (int encoding, const char *mbstr)
 
int pg_encoding_mblen_or_incomplete (int encoding, const char *mbstr, size_t remaining)
 
int pg_encoding_mblen_bounded (int encoding, const char *mbstr)
 
int pg_encoding_dsplen (int encoding, const char *mbstr)
 
int pg_encoding_verifymbchar (int encoding, const char *mbstr, int len)
 
int pg_encoding_verifymbstr (int encoding, const char *mbstr, int len)
 
int pg_encoding_max_length (int encoding)
 

Variables

static const uint32 Utf8Transition [256]
 
const pg_wchar_tbl pg_wchar_table []
 

Macro Definition Documentation

◆ ASC

#define ASC   (END << BGN)

Definition at line 1597 of file wchar.c.

◆ BGN

#define BGN   11

Definition at line 1581 of file wchar.c.

◆ CR1

#define CR1   (END << CS1) | (CS1 << CS2) | (CS2 << CS3) | (CS1 << P3B) | (CS2 << P4B)

Definition at line 1609 of file wchar.c.

◆ CR2

#define CR2   (END << CS1) | (CS1 << CS2) | (CS2 << CS3) | (CS1 << P3B) | (CS2 << P4A)

Definition at line 1610 of file wchar.c.

◆ CR3

#define CR3   (END << CS1) | (CS1 << CS2) | (CS2 << CS3) | (CS1 << P3A) | (CS2 << P4A)

Definition at line 1611 of file wchar.c.

◆ CS1

#define CS1   16

Definition at line 1583 of file wchar.c.

◆ CS2

#define CS2   1

Definition at line 1584 of file wchar.c.

◆ CS3

#define CS3   5

Definition at line 1585 of file wchar.c.

◆ END

#define END   BGN

Definition at line 1592 of file wchar.c.

◆ ERR

#define ERR   0

Definition at line 1579 of file wchar.c.

◆ ILL

#define ILL   ERR

Definition at line 1613 of file wchar.c.

◆ IS_EUC_RANGE_VALID

#define IS_EUC_RANGE_VALID (   c)    ((c) >= 0xa1 && (c) <= 0xfe)

Definition at line 929 of file wchar.c.

◆ L2A

#define L2A   (CS1 << BGN)

Definition at line 1599 of file wchar.c.

◆ L3A

#define L3A   (P3A << BGN)

Definition at line 1601 of file wchar.c.

◆ L3B

#define L3B   (CS2 << BGN)

Definition at line 1602 of file wchar.c.

◆ L3C

#define L3C   (P3B << BGN)

Definition at line 1603 of file wchar.c.

◆ L4A

#define L4A   (P4A << BGN)

Definition at line 1605 of file wchar.c.

◆ L4B

#define L4B   (CS3 << BGN)

Definition at line 1606 of file wchar.c.

◆ L4C

#define L4C   (P4B << BGN)

Definition at line 1607 of file wchar.c.

◆ MB2CHAR_NEED_AT_LEAST

#define MB2CHAR_NEED_AT_LEAST (   len,
  need 
)    if ((len) < (need)) break

Definition at line 67 of file wchar.c.

◆ NONUTF8_INVALID_BYTE0

#define NONUTF8_INVALID_BYTE0   (0x8d)

Definition at line 36 of file wchar.c.

◆ NONUTF8_INVALID_BYTE1

#define NONUTF8_INVALID_BYTE1   (' ')

Definition at line 37 of file wchar.c.

◆ P3A

#define P3A   6 /* Lead was E0, check for 3-byte overlong */

Definition at line 1587 of file wchar.c.

◆ P3B

#define P3B   20 /* Lead was ED, check for surrogate */

Definition at line 1588 of file wchar.c.

◆ P4A

#define P4A   25 /* Lead was F0, check for 4-byte overlong */

Definition at line 1589 of file wchar.c.

◆ P4B

#define P4B   30 /* Lead was F4, check for too-large */

Definition at line 1590 of file wchar.c.

◆ pg_euccn_verifychar

#define pg_euccn_verifychar   pg_euckr_verifychar

Definition at line 1074 of file wchar.c.

◆ pg_euccn_verifystr

#define pg_euccn_verifystr   pg_euckr_verifystr

Definition at line 1075 of file wchar.c.

◆ STRIDE_LENGTH

#define STRIDE_LENGTH   (2 * sizeof(Vector8))

Function Documentation

◆ mbbisearch()

static int mbbisearch ( pg_wchar  ucs,
const struct mbinterval table,
int  max 
)
static

Definition at line 599 of file wchar.c.

600{
601 int min = 0;
602 int mid;
603
604 if (ucs < table[0].first || ucs > table[max].last)
605 return 0;
606 while (max >= min)
607 {
608 mid = (min + max) / 2;
609 if (ucs > table[mid].last)
610 min = mid + 1;
611 else if (ucs < table[mid].first)
612 max = mid - 1;
613 else
614 return 1;
615 }
616
617 return 0;
618}
static const struct lconv_member_info table[]
static int fb(int x)

References fb(), and table.

Referenced by ucs_wcwidth().

◆ pg_ascii2wchar_with_len()

static int pg_ascii2wchar_with_len ( const unsigned char from,
pg_wchar to,
int  len 
)
static

Definition at line 73 of file wchar.c.

74{
75 int cnt = 0;
76
77 while (len > 0 && *from)
78 {
79 *to++ = *from++;
80 len--;
81 cnt++;
82 }
83 *to = 0;
84 return cnt;
85}
const void size_t len

References len.

◆ pg_ascii_dsplen()

static int pg_ascii_dsplen ( const unsigned char s)
static

Definition at line 94 of file wchar.c.

95{
96 if (*s == '\0')
97 return 0;
98 if (*s < 0x20 || *s == 0x7f)
99 return -1;
100
101 return 1;
102}

Referenced by pg_big5_dsplen(), pg_euc_dsplen(), pg_euccn_dsplen(), pg_eucjp_dsplen(), pg_euctw_dsplen(), pg_gb18030_dsplen(), pg_gbk_dsplen(), pg_latin1_dsplen(), pg_sjis_dsplen(), and pg_uhc_dsplen().

◆ pg_ascii_mblen()

static int pg_ascii_mblen ( const unsigned char s)
static

Definition at line 88 of file wchar.c.

89{
90 return 1;
91}

◆ pg_ascii_verifychar()

static int pg_ascii_verifychar ( const unsigned char s,
int  len 
)
static

Definition at line 913 of file wchar.c.

914{
915 return 1;
916}

◆ pg_ascii_verifystr()

static int pg_ascii_verifystr ( const unsigned char s,
int  len 
)
static

Definition at line 919 of file wchar.c.

920{
921 const unsigned char *nullpos = memchr(s, 0, len);
922
923 if (nullpos == NULL)
924 return len;
925 else
926 return nullpos - s;
927}

References fb(), and len.

◆ pg_big5_dsplen()

static int pg_big5_dsplen ( const unsigned char s)
static

Definition at line 784 of file wchar.c.

785{
786 int len;
787
788 if (IS_HIGHBIT_SET(*s))
789 len = 2; /* kanji? */
790 else
791 len = pg_ascii_dsplen(s); /* should be ASCII */
792 return len;
793}
#define IS_HIGHBIT_SET(ch)
Definition c.h:1244
static int pg_ascii_dsplen(const unsigned char *s)
Definition wchar.c:94

References IS_HIGHBIT_SET, len, and pg_ascii_dsplen().

◆ pg_big5_mblen()

static int pg_big5_mblen ( const unsigned char s)
static

Definition at line 772 of file wchar.c.

773{
774 int len;
775
776 if (IS_HIGHBIT_SET(*s))
777 len = 2; /* kanji? */
778 else
779 len = 1; /* should be ASCII */
780 return len;
781}

References IS_HIGHBIT_SET, and len.

Referenced by pg_big5_verifychar().

◆ pg_big5_verifychar()

static int pg_big5_verifychar ( const unsigned char s,
int  len 
)
static

Definition at line 1279 of file wchar.c.

1280{
1281 int l,
1282 mbl;
1283
1284 l = mbl = pg_big5_mblen(s);
1285
1286 if (len < l)
1287 return -1;
1288
1289 if (l == 2 &&
1290 s[0] == NONUTF8_INVALID_BYTE0 &&
1291 s[1] == NONUTF8_INVALID_BYTE1)
1292 return -1;
1293
1294 while (--l > 0)
1295 {
1296 if (*++s == '\0')
1297 return -1;
1298 }
1299
1300 return mbl;
1301}
#define NONUTF8_INVALID_BYTE0
Definition wchar.c:36
static int pg_big5_mblen(const unsigned char *s)
Definition wchar.c:772
#define NONUTF8_INVALID_BYTE1
Definition wchar.c:37

References fb(), len, NONUTF8_INVALID_BYTE0, NONUTF8_INVALID_BYTE1, and pg_big5_mblen().

Referenced by pg_big5_verifystr().

◆ pg_big5_verifystr()

static int pg_big5_verifystr ( const unsigned char s,
int  len 
)
static

Definition at line 1304 of file wchar.c.

1305{
1306 const unsigned char *start = s;
1307
1308 while (len > 0)
1309 {
1310 int l;
1311
1312 /* fast path for ASCII-subset characters */
1313 if (!IS_HIGHBIT_SET(*s))
1314 {
1315 if (*s == '\0')
1316 break;
1317 l = 1;
1318 }
1319 else
1320 {
1321 l = pg_big5_verifychar(s, len);
1322 if (l == -1)
1323 break;
1324 }
1325 s += l;
1326 len -= l;
1327 }
1328
1329 return s - start;
1330}
return str start
static int pg_big5_verifychar(const unsigned char *s, int len)
Definition wchar.c:1279

References IS_HIGHBIT_SET, len, pg_big5_verifychar(), and start.

◆ pg_encoding_dsplen()

int pg_encoding_dsplen ( int  encoding,
const char mbstr 
)

Definition at line 1975 of file wchar.c.

1976{
1977 return (PG_VALID_ENCODING(encoding) ?
1978 pg_wchar_table[encoding].dsplen((const unsigned char *) mbstr) :
1980}
static char * encoding
Definition initdb.c:139
@ PG_SQL_ASCII
Definition pg_wchar.h:76
#define PG_VALID_ENCODING(_enc)
Definition pg_wchar.h:140
const pg_wchar_tbl pg_wchar_table[]
Definition wchar.c:1864

References pg_wchar_tbl::dsplen, encoding, fb(), PG_SQL_ASCII, PG_VALID_ENCODING, and pg_wchar_table.

Referenced by PQdsplen(), and reportErrorPosition().

◆ pg_encoding_max_length()

int pg_encoding_max_length ( int  encoding)

Definition at line 2012 of file wchar.c.

2013{
2015
2016 /*
2017 * Check for the encoding despite the assert, due to some mingw versions
2018 * otherwise issuing bogus warnings.
2019 */
2020 return PG_VALID_ENCODING(encoding) ?
2023}
#define Assert(condition)
Definition c.h:943

References Assert, encoding, pg_wchar_tbl::maxmblen, PG_SQL_ASCII, PG_VALID_ENCODING, and pg_wchar_table.

Referenced by ascii(), chr(), CopyConvertBuf(), make_trigrams(), pg_encoding_mbcliplen(), pg_encoding_set_invalid(), pg_verify_mbstr_len(), reportErrorPosition(), test_enc_setup(), test_wchars_to_text(), and type_maximum_size().

◆ pg_encoding_mblen()

◆ pg_encoding_mblen_bounded()

int pg_encoding_mblen_bounded ( int  encoding,
const char mbstr 
)

Definition at line 1966 of file wchar.c.

1967{
1969}
int pg_encoding_mblen(int encoding, const char *mbstr)
Definition wchar.c:1934

References encoding, fb(), and pg_encoding_mblen().

◆ pg_encoding_mblen_or_incomplete()

int pg_encoding_mblen_or_incomplete ( int  encoding,
const char mbstr,
size_t  remaining 
)

Definition at line 1946 of file wchar.c.

1948{
1949 /*
1950 * Define zero remaining as too few, even for single-byte encodings.
1951 * pg_gb18030_mblen() reads one or two bytes; single-byte encodings read
1952 * zero; others read one.
1953 */
1954 if (remaining < 1 ||
1956 return INT_MAX;
1958}
int remaining
Definition informix.c:692
@ PG_GB18030
Definition pg_wchar.h:118

References encoding, fb(), IS_HIGHBIT_SET, pg_encoding_mblen(), PG_GB18030, and remaining.

Referenced by PQescapeInternal(), PQescapeStringInternal(), report_invalid_encoding(), and report_untranslatable_char().

◆ pg_encoding_set_invalid()

void pg_encoding_set_invalid ( int  encoding,
char dst 
)

Definition at line 1851 of file wchar.c.

1852{
1854
1855 dst[0] = (encoding == PG_UTF8 ? 0xc0 : NONUTF8_INVALID_BYTE0);
1857}
#define PG_UTF8
Definition mbprint.c:43
int pg_encoding_max_length(int encoding)
Definition wchar.c:2012

References Assert, encoding, fb(), NONUTF8_INVALID_BYTE0, NONUTF8_INVALID_BYTE1, pg_encoding_max_length(), and PG_UTF8.

Referenced by appendStringLiteral(), fmtIdEnc(), PQescapeStringInternal(), and test_enc_setup().

◆ pg_encoding_verifymbchar()

int pg_encoding_verifymbchar ( int  encoding,
const char mbstr,
int  len 
)

◆ pg_encoding_verifymbstr()

int pg_encoding_verifymbstr ( int  encoding,
const char mbstr,
int  len 
)

◆ pg_euc2wchar_with_len()

static int pg_euc2wchar_with_len ( const unsigned char from,
pg_wchar to,
int  len 
)
static

Definition at line 108 of file wchar.c.

109{
110 int cnt = 0;
111
112 while (len > 0 && *from)
113 {
114 if (*from == SS2) /* JIS X 0201 (so called "1 byte KANA") */
115 {
117 from++;
118 *to = (SS2 << 8) | *from++;
119 len -= 2;
120 }
121 else if (*from == SS3) /* JIS X 0212 KANJI */
122 {
124 from++;
125 *to = (SS3 << 16) | (*from++ << 8);
126 *to |= *from++;
127 len -= 3;
128 }
129 else if (IS_HIGHBIT_SET(*from)) /* JIS X 0208 KANJI */
130 {
132 *to = *from++ << 8;
133 *to |= *from++;
134 len -= 2;
135 }
136 else /* must be ASCII */
137 {
138 *to = *from++;
139 len--;
140 }
141 to++;
142 cnt++;
143 }
144 *to = 0;
145 return cnt;
146}
#define SS2
Definition pg_wchar.h:38
#define SS3
Definition pg_wchar.h:39
#define MB2CHAR_NEED_AT_LEAST(len, need)
Definition wchar.c:67

References IS_HIGHBIT_SET, len, MB2CHAR_NEED_AT_LEAST, SS2, and SS3.

Referenced by pg_eucjp2wchar_with_len(), and pg_euckr2wchar_with_len().

◆ pg_euc_dsplen()

static int pg_euc_dsplen ( const unsigned char s)
inlinestatic

Definition at line 165 of file wchar.c.

166{
167 int len;
168
169 if (*s == SS2)
170 len = 2;
171 else if (*s == SS3)
172 len = 2;
173 else if (IS_HIGHBIT_SET(*s))
174 len = 2;
175 else
176 len = pg_ascii_dsplen(s);
177 return len;
178}

References IS_HIGHBIT_SET, len, pg_ascii_dsplen(), SS2, and SS3.

Referenced by pg_euckr_dsplen(), and pg_johab_dsplen().

◆ pg_euc_mblen()

static int pg_euc_mblen ( const unsigned char s)
inlinestatic

Definition at line 149 of file wchar.c.

150{
151 int len;
152
153 if (*s == SS2)
154 len = 2;
155 else if (*s == SS3)
156 len = 3;
157 else if (IS_HIGHBIT_SET(*s))
158 len = 2;
159 else
160 len = 1;
161 return len;
162}

References IS_HIGHBIT_SET, len, SS2, and SS3.

Referenced by pg_eucjp_mblen(), pg_euckr_mblen(), and pg_johab_mblen().

◆ pg_euccn2wchar_with_len()

static int pg_euccn2wchar_with_len ( const unsigned char from,
pg_wchar to,
int  len 
)
static

Definition at line 237 of file wchar.c.

238{
239 int cnt = 0;
240
241 while (len > 0 && *from)
242 {
243 if (*from == SS2) /* code set 2 (unused?) */
244 {
246 from++;
247 *to = (SS2 << 16) | (*from++ << 8);
248 *to |= *from++;
249 len -= 3;
250 }
251 else if (*from == SS3) /* code set 3 (unused ?) */
252 {
254 from++;
255 *to = (SS3 << 16) | (*from++ << 8);
256 *to |= *from++;
257 len -= 3;
258 }
259 else if (IS_HIGHBIT_SET(*from)) /* code set 1 */
260 {
262 *to = *from++ << 8;
263 *to |= *from++;
264 len -= 2;
265 }
266 else
267 {
268 *to = *from++;
269 len--;
270 }
271 to++;
272 cnt++;
273 }
274 *to = 0;
275 return cnt;
276}

References IS_HIGHBIT_SET, len, MB2CHAR_NEED_AT_LEAST, SS2, and SS3.

◆ pg_euccn_dsplen()

static int pg_euccn_dsplen ( const unsigned char s)
static

Definition at line 301 of file wchar.c.

302{
303 int len;
304
305 if (IS_HIGHBIT_SET(*s))
306 len = 2;
307 else
308 len = pg_ascii_dsplen(s);
309 return len;
310}

References IS_HIGHBIT_SET, len, and pg_ascii_dsplen().

◆ pg_euccn_mblen()

static int pg_euccn_mblen ( const unsigned char s)
static

Definition at line 285 of file wchar.c.

286{
287 int len;
288
289 if (*s == SS2)
290 len = 3;
291 else if (*s == SS3)
292 len = 3;
293 else if (IS_HIGHBIT_SET(*s))
294 len = 2;
295 else
296 len = 1;
297 return len;
298}

References IS_HIGHBIT_SET, len, SS2, and SS3.

◆ pg_eucjp2wchar_with_len()

static int pg_eucjp2wchar_with_len ( const unsigned char from,
pg_wchar to,
int  len 
)
static

Definition at line 184 of file wchar.c.

185{
186 return pg_euc2wchar_with_len(from, to, len);
187}
static int pg_euc2wchar_with_len(const unsigned char *from, pg_wchar *to, int len)
Definition wchar.c:108

References len, and pg_euc2wchar_with_len().

◆ pg_eucjp_dsplen()

static int pg_eucjp_dsplen ( const unsigned char s)
static

Definition at line 196 of file wchar.c.

197{
198 int len;
199
200 if (*s == SS2)
201 len = 1;
202 else if (*s == SS3)
203 len = 2;
204 else if (IS_HIGHBIT_SET(*s))
205 len = 2;
206 else
207 len = pg_ascii_dsplen(s);
208 return len;
209}

References IS_HIGHBIT_SET, len, pg_ascii_dsplen(), SS2, and SS3.

◆ pg_eucjp_mblen()

static int pg_eucjp_mblen ( const unsigned char s)
static

Definition at line 190 of file wchar.c.

191{
192 return pg_euc_mblen(s);
193}
static int pg_euc_mblen(const unsigned char *s)
Definition wchar.c:149

References pg_euc_mblen().

◆ pg_eucjp_verifychar()

static int pg_eucjp_verifychar ( const unsigned char s,
int  len 
)
static

Definition at line 932 of file wchar.c.

933{
934 int l;
935 unsigned char c1,
936 c2;
937
938 c1 = *s++;
939
940 switch (c1)
941 {
942 case SS2: /* JIS X 0201 */
943 l = 2;
944 if (l > len)
945 return -1;
946 c2 = *s++;
947 if (c2 < 0xa1 || c2 > 0xdf)
948 return -1;
949 break;
950
951 case SS3: /* JIS X 0212 */
952 l = 3;
953 if (l > len)
954 return -1;
955 c2 = *s++;
957 return -1;
958 c2 = *s++;
960 return -1;
961 break;
962
963 default:
964 if (IS_HIGHBIT_SET(c1)) /* JIS X 0208? */
965 {
966 l = 2;
967 if (l > len)
968 return -1;
970 return -1;
971 c2 = *s++;
973 return -1;
974 }
975 else
976 /* must be ASCII */
977 {
978 l = 1;
979 }
980 break;
981 }
982
983 return l;
984}
#define IS_EUC_RANGE_VALID(c)
Definition wchar.c:929

References fb(), IS_EUC_RANGE_VALID, IS_HIGHBIT_SET, len, SS2, and SS3.

Referenced by pg_eucjp_verifystr().

◆ pg_eucjp_verifystr()

static int pg_eucjp_verifystr ( const unsigned char s,
int  len 
)
static

Definition at line 987 of file wchar.c.

988{
989 const unsigned char *start = s;
990
991 while (len > 0)
992 {
993 int l;
994
995 /* fast path for ASCII-subset characters */
996 if (!IS_HIGHBIT_SET(*s))
997 {
998 if (*s == '\0')
999 break;
1000 l = 1;
1001 }
1002 else
1003 {
1004 l = pg_eucjp_verifychar(s, len);
1005 if (l == -1)
1006 break;
1007 }
1008 s += l;
1009 len -= l;
1010 }
1011
1012 return s - start;
1013}
static int pg_eucjp_verifychar(const unsigned char *s, int len)
Definition wchar.c:932

References IS_HIGHBIT_SET, len, pg_eucjp_verifychar(), and start.

◆ pg_euckr2wchar_with_len()

static int pg_euckr2wchar_with_len ( const unsigned char from,
pg_wchar to,
int  len 
)
static

Definition at line 215 of file wchar.c.

216{
217 return pg_euc2wchar_with_len(from, to, len);
218}

References len, and pg_euc2wchar_with_len().

◆ pg_euckr_dsplen()

static int pg_euckr_dsplen ( const unsigned char s)
static

Definition at line 227 of file wchar.c.

228{
229 return pg_euc_dsplen(s);
230}
static int pg_euc_dsplen(const unsigned char *s)
Definition wchar.c:165

References pg_euc_dsplen().

◆ pg_euckr_mblen()

static int pg_euckr_mblen ( const unsigned char s)
static

Definition at line 221 of file wchar.c.

222{
223 return pg_euc_mblen(s);
224}

References pg_euc_mblen().

◆ pg_euckr_verifychar()

static int pg_euckr_verifychar ( const unsigned char s,
int  len 
)
static

Definition at line 1016 of file wchar.c.

1017{
1018 int l;
1019 unsigned char c1,
1020 c2;
1021
1022 c1 = *s++;
1023
1024 if (IS_HIGHBIT_SET(c1))
1025 {
1026 l = 2;
1027 if (l > len)
1028 return -1;
1029 if (!IS_EUC_RANGE_VALID(c1))
1030 return -1;
1031 c2 = *s++;
1032 if (!IS_EUC_RANGE_VALID(c2))
1033 return -1;
1034 }
1035 else
1036 /* must be ASCII */
1037 {
1038 l = 1;
1039 }
1040
1041 return l;
1042}

References fb(), IS_EUC_RANGE_VALID, IS_HIGHBIT_SET, and len.

Referenced by pg_euckr_verifystr().

◆ pg_euckr_verifystr()

static int pg_euckr_verifystr ( const unsigned char s,
int  len 
)
static

Definition at line 1045 of file wchar.c.

1046{
1047 const unsigned char *start = s;
1048
1049 while (len > 0)
1050 {
1051 int l;
1052
1053 /* fast path for ASCII-subset characters */
1054 if (!IS_HIGHBIT_SET(*s))
1055 {
1056 if (*s == '\0')
1057 break;
1058 l = 1;
1059 }
1060 else
1061 {
1062 l = pg_euckr_verifychar(s, len);
1063 if (l == -1)
1064 break;
1065 }
1066 s += l;
1067 len -= l;
1068 }
1069
1070 return s - start;
1071}
static int pg_euckr_verifychar(const unsigned char *s, int len)
Definition wchar.c:1016

References IS_HIGHBIT_SET, len, pg_euckr_verifychar(), and start.

◆ pg_euctw2wchar_with_len()

static int pg_euctw2wchar_with_len ( const unsigned char from,
pg_wchar to,
int  len 
)
static

Definition at line 317 of file wchar.c.

318{
319 int cnt = 0;
320
321 while (len > 0 && *from)
322 {
323 if (*from == SS2) /* code set 2 */
324 {
326 from++;
327 *to = (((uint32) SS2) << 24) | (*from++ << 16);
328 *to |= *from++ << 8;
329 *to |= *from++;
330 len -= 4;
331 }
332 else if (*from == SS3) /* code set 3 (unused?) */
333 {
335 from++;
336 *to = (SS3 << 16) | (*from++ << 8);
337 *to |= *from++;
338 len -= 3;
339 }
340 else if (IS_HIGHBIT_SET(*from)) /* code set 2 */
341 {
343 *to = *from++ << 8;
344 *to |= *from++;
345 len -= 2;
346 }
347 else
348 {
349 *to = *from++;
350 len--;
351 }
352 to++;
353 cnt++;
354 }
355 *to = 0;
356 return cnt;
357}
uint32_t uint32
Definition c.h:624

References IS_HIGHBIT_SET, len, MB2CHAR_NEED_AT_LEAST, SS2, and SS3.

◆ pg_euctw_dsplen()

static int pg_euctw_dsplen ( const unsigned char s)
static

Definition at line 376 of file wchar.c.

377{
378 int len;
379
380 if (*s == SS2)
381 len = 2;
382 else if (*s == SS3)
383 len = 2;
384 else if (IS_HIGHBIT_SET(*s))
385 len = 2;
386 else
387 len = pg_ascii_dsplen(s);
388 return len;
389}

References IS_HIGHBIT_SET, len, pg_ascii_dsplen(), SS2, and SS3.

◆ pg_euctw_mblen()

static int pg_euctw_mblen ( const unsigned char s)
static

Definition at line 360 of file wchar.c.

361{
362 int len;
363
364 if (*s == SS2)
365 len = 4;
366 else if (*s == SS3)
367 len = 3;
368 else if (IS_HIGHBIT_SET(*s))
369 len = 2;
370 else
371 len = 1;
372 return len;
373}

References IS_HIGHBIT_SET, len, SS2, and SS3.

◆ pg_euctw_verifychar()

static int pg_euctw_verifychar ( const unsigned char s,
int  len 
)
static

Definition at line 1078 of file wchar.c.

1079{
1080 int l;
1081 unsigned char c1,
1082 c2;
1083
1084 c1 = *s++;
1085
1086 switch (c1)
1087 {
1088 case SS2: /* CNS 11643 Plane 1-7 */
1089 l = 4;
1090 if (l > len)
1091 return -1;
1092 c2 = *s++;
1093 if (c2 < 0xa1 || c2 > 0xa7)
1094 return -1;
1095 c2 = *s++;
1096 if (!IS_EUC_RANGE_VALID(c2))
1097 return -1;
1098 c2 = *s++;
1099 if (!IS_EUC_RANGE_VALID(c2))
1100 return -1;
1101 break;
1102
1103 case SS3: /* unused */
1104 return -1;
1105
1106 default:
1107 if (IS_HIGHBIT_SET(c1)) /* CNS 11643 Plane 1 */
1108 {
1109 l = 2;
1110 if (l > len)
1111 return -1;
1112 /* no further range check on c1? */
1113 c2 = *s++;
1114 if (!IS_EUC_RANGE_VALID(c2))
1115 return -1;
1116 }
1117 else
1118 /* must be ASCII */
1119 {
1120 l = 1;
1121 }
1122 break;
1123 }
1124 return l;
1125}

References fb(), IS_EUC_RANGE_VALID, IS_HIGHBIT_SET, len, SS2, and SS3.

Referenced by pg_euctw_verifystr().

◆ pg_euctw_verifystr()

static int pg_euctw_verifystr ( const unsigned char s,
int  len 
)
static

Definition at line 1128 of file wchar.c.

1129{
1130 const unsigned char *start = s;
1131
1132 while (len > 0)
1133 {
1134 int l;
1135
1136 /* fast path for ASCII-subset characters */
1137 if (!IS_HIGHBIT_SET(*s))
1138 {
1139 if (*s == '\0')
1140 break;
1141 l = 1;
1142 }
1143 else
1144 {
1145 l = pg_euctw_verifychar(s, len);
1146 if (l == -1)
1147 break;
1148 }
1149 s += l;
1150 len -= l;
1151 }
1152
1153 return s - start;
1154}
static int pg_euctw_verifychar(const unsigned char *s, int len)
Definition wchar.c:1078

References IS_HIGHBIT_SET, len, pg_euctw_verifychar(), and start.

◆ pg_gb18030_dsplen()

static int pg_gb18030_dsplen ( const unsigned char s)
static

Definition at line 879 of file wchar.c.

880{
881 int len;
882
883 if (IS_HIGHBIT_SET(*s))
884 len = 2;
885 else
886 len = pg_ascii_dsplen(s); /* ASCII */
887 return len;
888}

References IS_HIGHBIT_SET, len, and pg_ascii_dsplen().

◆ pg_gb18030_mblen()

static int pg_gb18030_mblen ( const unsigned char s)
static

Definition at line 865 of file wchar.c.

866{
867 int len;
868
869 if (!IS_HIGHBIT_SET(*s))
870 len = 1; /* ASCII */
871 else if (*(s + 1) >= 0x30 && *(s + 1) <= 0x39)
872 len = 4;
873 else
874 len = 2;
875 return len;
876}

References IS_HIGHBIT_SET, and len.

◆ pg_gb18030_verifychar()

static int pg_gb18030_verifychar ( const unsigned char s,
int  len 
)
static

Definition at line 1441 of file wchar.c.

1442{
1443 int l;
1444
1445 if (!IS_HIGHBIT_SET(*s))
1446 l = 1; /* ASCII */
1447 else if (len >= 4 && *(s + 1) >= 0x30 && *(s + 1) <= 0x39)
1448 {
1449 /* Should be 4-byte, validate remaining bytes */
1450 if (*s >= 0x81 && *s <= 0xfe &&
1451 *(s + 2) >= 0x81 && *(s + 2) <= 0xfe &&
1452 *(s + 3) >= 0x30 && *(s + 3) <= 0x39)
1453 l = 4;
1454 else
1455 l = -1;
1456 }
1457 else if (len >= 2 && *s >= 0x81 && *s <= 0xfe)
1458 {
1459 /* Should be 2-byte, validate */
1460 if ((*(s + 1) >= 0x40 && *(s + 1) <= 0x7e) ||
1461 (*(s + 1) >= 0x80 && *(s + 1) <= 0xfe))
1462 l = 2;
1463 else
1464 l = -1;
1465 }
1466 else
1467 l = -1;
1468 return l;
1469}

References IS_HIGHBIT_SET, and len.

Referenced by pg_gb18030_verifystr().

◆ pg_gb18030_verifystr()

static int pg_gb18030_verifystr ( const unsigned char s,
int  len 
)
static

Definition at line 1472 of file wchar.c.

1473{
1474 const unsigned char *start = s;
1475
1476 while (len > 0)
1477 {
1478 int l;
1479
1480 /* fast path for ASCII-subset characters */
1481 if (!IS_HIGHBIT_SET(*s))
1482 {
1483 if (*s == '\0')
1484 break;
1485 l = 1;
1486 }
1487 else
1488 {
1489 l = pg_gb18030_verifychar(s, len);
1490 if (l == -1)
1491 break;
1492 }
1493 s += l;
1494 len -= l;
1495 }
1496
1497 return s - start;
1498}
static int pg_gb18030_verifychar(const unsigned char *s, int len)
Definition wchar.c:1441

References IS_HIGHBIT_SET, len, pg_gb18030_verifychar(), and start.

◆ pg_gbk_dsplen()

static int pg_gbk_dsplen ( const unsigned char s)
static

Definition at line 811 of file wchar.c.

812{
813 int len;
814
815 if (IS_HIGHBIT_SET(*s))
816 len = 2; /* kanji? */
817 else
818 len = pg_ascii_dsplen(s); /* should be ASCII */
819 return len;
820}

References IS_HIGHBIT_SET, len, and pg_ascii_dsplen().

◆ pg_gbk_mblen()

static int pg_gbk_mblen ( const unsigned char s)
static

Definition at line 799 of file wchar.c.

800{
801 int len;
802
803 if (IS_HIGHBIT_SET(*s))
804 len = 2; /* kanji? */
805 else
806 len = 1; /* should be ASCII */
807 return len;
808}

References IS_HIGHBIT_SET, and len.

Referenced by pg_gbk_verifychar().

◆ pg_gbk_verifychar()

static int pg_gbk_verifychar ( const unsigned char s,
int  len 
)
static

Definition at line 1333 of file wchar.c.

1334{
1335 int l,
1336 mbl;
1337
1338 l = mbl = pg_gbk_mblen(s);
1339
1340 if (len < l)
1341 return -1;
1342
1343 if (l == 2 &&
1344 s[0] == NONUTF8_INVALID_BYTE0 &&
1345 s[1] == NONUTF8_INVALID_BYTE1)
1346 return -1;
1347
1348 while (--l > 0)
1349 {
1350 if (*++s == '\0')
1351 return -1;
1352 }
1353
1354 return mbl;
1355}
static int pg_gbk_mblen(const unsigned char *s)
Definition wchar.c:799

References fb(), len, NONUTF8_INVALID_BYTE0, NONUTF8_INVALID_BYTE1, and pg_gbk_mblen().

Referenced by pg_gbk_verifystr().

◆ pg_gbk_verifystr()

static int pg_gbk_verifystr ( const unsigned char s,
int  len 
)
static

Definition at line 1358 of file wchar.c.

1359{
1360 const unsigned char *start = s;
1361
1362 while (len > 0)
1363 {
1364 int l;
1365
1366 /* fast path for ASCII-subset characters */
1367 if (!IS_HIGHBIT_SET(*s))
1368 {
1369 if (*s == '\0')
1370 break;
1371 l = 1;
1372 }
1373 else
1374 {
1375 l = pg_gbk_verifychar(s, len);
1376 if (l == -1)
1377 break;
1378 }
1379 s += l;
1380 len -= l;
1381 }
1382
1383 return s - start;
1384}
static int pg_gbk_verifychar(const unsigned char *s, int len)
Definition wchar.c:1333

References IS_HIGHBIT_SET, len, pg_gbk_verifychar(), and start.

◆ pg_johab_dsplen()

static int pg_johab_dsplen ( const unsigned char s)
static

Definition at line 450 of file wchar.c.

451{
452 return pg_euc_dsplen(s);
453}

References pg_euc_dsplen().

◆ pg_johab_mblen()

static int pg_johab_mblen ( const unsigned char s)
static

Definition at line 444 of file wchar.c.

445{
446 return pg_euc_mblen(s);
447}

References pg_euc_mblen().

Referenced by pg_johab_verifychar().

◆ pg_johab_verifychar()

static int pg_johab_verifychar ( const unsigned char s,
int  len 
)
static

Definition at line 1157 of file wchar.c.

1158{
1159 int l,
1160 mbl;
1161 unsigned char c;
1162
1163 l = mbl = pg_johab_mblen(s);
1164
1165 if (len < l)
1166 return -1;
1167
1168 if (!IS_HIGHBIT_SET(*s))
1169 return mbl;
1170
1171 while (--l > 0)
1172 {
1173 c = *++s;
1174 if (!IS_EUC_RANGE_VALID(c))
1175 return -1;
1176 }
1177 return mbl;
1178}
char * c
static int pg_johab_mblen(const unsigned char *s)
Definition wchar.c:444

References fb(), IS_EUC_RANGE_VALID, IS_HIGHBIT_SET, len, and pg_johab_mblen().

Referenced by pg_johab_verifystr().

◆ pg_johab_verifystr()

static int pg_johab_verifystr ( const unsigned char s,
int  len 
)
static

Definition at line 1181 of file wchar.c.

1182{
1183 const unsigned char *start = s;
1184
1185 while (len > 0)
1186 {
1187 int l;
1188
1189 /* fast path for ASCII-subset characters */
1190 if (!IS_HIGHBIT_SET(*s))
1191 {
1192 if (*s == '\0')
1193 break;
1194 l = 1;
1195 }
1196 else
1197 {
1198 l = pg_johab_verifychar(s, len);
1199 if (l == -1)
1200 break;
1201 }
1202 s += l;
1203 len -= l;
1204 }
1205
1206 return s - start;
1207}
static int pg_johab_verifychar(const unsigned char *s, int len)
Definition wchar.c:1157

References IS_HIGHBIT_SET, len, pg_johab_verifychar(), and start.

◆ pg_latin12wchar_with_len()

static int pg_latin12wchar_with_len ( const unsigned char from,
pg_wchar to,
int  len 
)
static

Definition at line 689 of file wchar.c.

690{
691 int cnt = 0;
692
693 while (len > 0 && *from)
694 {
695 *to++ = *from++;
696 len--;
697 cnt++;
698 }
699 *to = 0;
700 return cnt;
701}

References len.

◆ pg_latin1_dsplen()

static int pg_latin1_dsplen ( const unsigned char s)
static

Definition at line 732 of file wchar.c.

733{
734 return pg_ascii_dsplen(s);
735}

References pg_ascii_dsplen().

◆ pg_latin1_mblen()

static int pg_latin1_mblen ( const unsigned char s)
static

Definition at line 726 of file wchar.c.

727{
728 return 1;
729}

◆ pg_latin1_verifychar()

static int pg_latin1_verifychar ( const unsigned char s,
int  len 
)
static

Definition at line 1210 of file wchar.c.

1211{
1212 return 1;
1213}

◆ pg_latin1_verifystr()

static int pg_latin1_verifystr ( const unsigned char s,
int  len 
)
static

Definition at line 1216 of file wchar.c.

1217{
1218 const unsigned char *nullpos = memchr(s, 0, len);
1219
1220 if (nullpos == NULL)
1221 return len;
1222 else
1223 return nullpos - s;
1224}

References fb(), and len.

◆ pg_sjis_dsplen()

static int pg_sjis_dsplen ( const unsigned char s)
static

Definition at line 755 of file wchar.c.

756{
757 int len;
758
759 if (*s >= 0xa1 && *s <= 0xdf)
760 len = 1; /* 1 byte kana? */
761 else if (IS_HIGHBIT_SET(*s))
762 len = 2; /* kanji? */
763 else
764 len = pg_ascii_dsplen(s); /* should be ASCII */
765 return len;
766}

References IS_HIGHBIT_SET, len, and pg_ascii_dsplen().

◆ pg_sjis_mblen()

static int pg_sjis_mblen ( const unsigned char s)
static

Definition at line 741 of file wchar.c.

742{
743 int len;
744
745 if (*s >= 0xa1 && *s <= 0xdf)
746 len = 1; /* 1 byte kana? */
747 else if (IS_HIGHBIT_SET(*s))
748 len = 2; /* kanji? */
749 else
750 len = 1; /* should be ASCII */
751 return len;
752}

References IS_HIGHBIT_SET, and len.

Referenced by pg_sjis_verifychar().

◆ pg_sjis_verifychar()

static int pg_sjis_verifychar ( const unsigned char s,
int  len 
)
static

Definition at line 1227 of file wchar.c.

1228{
1229 int l,
1230 mbl;
1231 unsigned char c1,
1232 c2;
1233
1234 l = mbl = pg_sjis_mblen(s);
1235
1236 if (len < l)
1237 return -1;
1238
1239 if (l == 1) /* pg_sjis_mblen already verified it */
1240 return mbl;
1241
1242 c1 = *s++;
1243 c2 = *s;
1244 if (!ISSJISHEAD(c1) || !ISSJISTAIL(c2))
1245 return -1;
1246 return mbl;
1247}
#define ISSJISTAIL(c)
Definition pg_wchar.h:56
#define ISSJISHEAD(c)
Definition pg_wchar.h:55
static int pg_sjis_mblen(const unsigned char *s)
Definition wchar.c:741

References fb(), ISSJISHEAD, ISSJISTAIL, len, and pg_sjis_mblen().

Referenced by pg_sjis_verifystr().

◆ pg_sjis_verifystr()

static int pg_sjis_verifystr ( const unsigned char s,
int  len 
)
static

Definition at line 1250 of file wchar.c.

1251{
1252 const unsigned char *start = s;
1253
1254 while (len > 0)
1255 {
1256 int l;
1257
1258 /* fast path for ASCII-subset characters */
1259 if (!IS_HIGHBIT_SET(*s))
1260 {
1261 if (*s == '\0')
1262 break;
1263 l = 1;
1264 }
1265 else
1266 {
1267 l = pg_sjis_verifychar(s, len);
1268 if (l == -1)
1269 break;
1270 }
1271 s += l;
1272 len -= l;
1273 }
1274
1275 return s - start;
1276}
static int pg_sjis_verifychar(const unsigned char *s, int len)
Definition wchar.c:1227

References IS_HIGHBIT_SET, len, pg_sjis_verifychar(), and start.

◆ pg_uhc_dsplen()

static int pg_uhc_dsplen ( const unsigned char s)
static

Definition at line 838 of file wchar.c.

839{
840 int len;
841
842 if (IS_HIGHBIT_SET(*s))
843 len = 2; /* 2byte? */
844 else
845 len = pg_ascii_dsplen(s); /* should be ASCII */
846 return len;
847}

References IS_HIGHBIT_SET, len, and pg_ascii_dsplen().

◆ pg_uhc_mblen()

static int pg_uhc_mblen ( const unsigned char s)
static

Definition at line 826 of file wchar.c.

827{
828 int len;
829
830 if (IS_HIGHBIT_SET(*s))
831 len = 2; /* 2byte? */
832 else
833 len = 1; /* should be ASCII */
834 return len;
835}

References IS_HIGHBIT_SET, and len.

Referenced by pg_uhc_verifychar().

◆ pg_uhc_verifychar()

static int pg_uhc_verifychar ( const unsigned char s,
int  len 
)
static

Definition at line 1387 of file wchar.c.

1388{
1389 int l,
1390 mbl;
1391
1392 l = mbl = pg_uhc_mblen(s);
1393
1394 if (len < l)
1395 return -1;
1396
1397 if (l == 2 &&
1398 s[0] == NONUTF8_INVALID_BYTE0 &&
1399 s[1] == NONUTF8_INVALID_BYTE1)
1400 return -1;
1401
1402 while (--l > 0)
1403 {
1404 if (*++s == '\0')
1405 return -1;
1406 }
1407
1408 return mbl;
1409}
static int pg_uhc_mblen(const unsigned char *s)
Definition wchar.c:826

References fb(), len, NONUTF8_INVALID_BYTE0, NONUTF8_INVALID_BYTE1, and pg_uhc_mblen().

Referenced by pg_uhc_verifystr().

◆ pg_uhc_verifystr()

static int pg_uhc_verifystr ( const unsigned char s,
int  len 
)
static

Definition at line 1412 of file wchar.c.

1413{
1414 const unsigned char *start = s;
1415
1416 while (len > 0)
1417 {
1418 int l;
1419
1420 /* fast path for ASCII-subset characters */
1421 if (!IS_HIGHBIT_SET(*s))
1422 {
1423 if (*s == '\0')
1424 break;
1425 l = 1;
1426 }
1427 else
1428 {
1429 l = pg_uhc_verifychar(s, len);
1430 if (l == -1)
1431 break;
1432 }
1433 s += l;
1434 len -= l;
1435 }
1436
1437 return s - start;
1438}
static int pg_uhc_verifychar(const unsigned char *s, int len)
Definition wchar.c:1387

References IS_HIGHBIT_SET, len, pg_uhc_verifychar(), and start.

◆ pg_utf2wchar_with_len()

static int pg_utf2wchar_with_len ( const unsigned char from,
pg_wchar to,
int  len 
)
static

Definition at line 462 of file wchar.c.

463{
464 int cnt = 0;
465 uint32 c1,
466 c2,
467 c3,
468 c4;
469
470 while (len > 0 && *from)
471 {
472 if ((*from & 0x80) == 0)
473 {
474 *to = *from++;
475 len--;
476 }
477 else if ((*from & 0xe0) == 0xc0)
478 {
480 c1 = *from++ & 0x1f;
481 c2 = *from++ & 0x3f;
482 *to = (c1 << 6) | c2;
483 len -= 2;
484 }
485 else if ((*from & 0xf0) == 0xe0)
486 {
488 c1 = *from++ & 0x0f;
489 c2 = *from++ & 0x3f;
490 c3 = *from++ & 0x3f;
491 *to = (c1 << 12) | (c2 << 6) | c3;
492 len -= 3;
493 }
494 else if ((*from & 0xf8) == 0xf0)
495 {
497 c1 = *from++ & 0x07;
498 c2 = *from++ & 0x3f;
499 c3 = *from++ & 0x3f;
500 c4 = *from++ & 0x3f;
501 *to = (c1 << 18) | (c2 << 12) | (c3 << 6) | c4;
502 len -= 4;
503 }
504 else
505 {
506 /* treat a bogus char as length 1; not ours to raise error */
507 *to = *from++;
508 len--;
509 }
510 to++;
511 cnt++;
512 }
513 *to = 0;
514 return cnt;
515}

References fb(), len, and MB2CHAR_NEED_AT_LEAST.

◆ pg_utf8_islegal()

bool pg_utf8_islegal ( const unsigned char source,
int  length 
)

Definition at line 1789 of file wchar.c.

1790{
1791 unsigned char a;
1792
1793 switch (length)
1794 {
1795 default:
1796 /* reject lengths 5 and 6 for now */
1797 return false;
1798 case 4:
1799 a = source[3];
1800 if (a < 0x80 || a > 0xBF)
1801 return false;
1803 case 3:
1804 a = source[2];
1805 if (a < 0x80 || a > 0xBF)
1806 return false;
1808 case 2:
1809 a = source[1];
1810 switch (*source)
1811 {
1812 case 0xE0:
1813 if (a < 0xA0 || a > 0xBF)
1814 return false;
1815 break;
1816 case 0xED:
1817 if (a < 0x80 || a > 0x9F)
1818 return false;
1819 break;
1820 case 0xF0:
1821 if (a < 0x90 || a > 0xBF)
1822 return false;
1823 break;
1824 case 0xF4:
1825 if (a < 0x80 || a > 0x8F)
1826 return false;
1827 break;
1828 default:
1829 if (a < 0x80 || a > 0xBF)
1830 return false;
1831 break;
1832 }
1834 case 1:
1835 a = *source;
1836 if (a >= 0x80 && a < 0xC2)
1837 return false;
1838 if (a > 0xF4)
1839 return false;
1840 break;
1841 }
1842 return true;
1843}
#define pg_fallthrough
Definition c.h:161
int a
Definition isn.c:73
static rewind_source * source
Definition pg_rewind.c:89

References a, fb(), pg_fallthrough, and source.

Referenced by chr(), pg_utf8_string_len(), pg_utf8_verifychar(), utf8_to_iso8859_1(), and UtfToLocal().

◆ pg_utf8_verifychar()

static int pg_utf8_verifychar ( const unsigned char s,
int  len 
)
static

Definition at line 1501 of file wchar.c.

1502{
1503 int l;
1504
1505 if ((*s & 0x80) == 0)
1506 {
1507 if (*s == '\0')
1508 return -1;
1509 return 1;
1510 }
1511 else if ((*s & 0xe0) == 0xc0)
1512 l = 2;
1513 else if ((*s & 0xf0) == 0xe0)
1514 l = 3;
1515 else if ((*s & 0xf8) == 0xf0)
1516 l = 4;
1517 else
1518 l = 1;
1519
1520 if (l > len)
1521 return -1;
1522
1523 if (!pg_utf8_islegal(s, l))
1524 return -1;
1525
1526 return l;
1527}
bool pg_utf8_islegal(const unsigned char *source, int length)
Definition wchar.c:1789

References len, and pg_utf8_islegal().

Referenced by pg_utf8_verifystr().

◆ pg_utf8_verifystr()

static int pg_utf8_verifystr ( const unsigned char s,
int  len 
)
static

Definition at line 1691 of file wchar.c.

1692{
1693 const unsigned char *start = s;
1694 const int orig_len = len;
1695 uint32 state = BGN;
1696
1697/*
1698 * With a stride of two vector widths, gcc will unroll the loop. Even if
1699 * the compiler can unroll a longer loop, it's not worth it because we
1700 * must fall back to the byte-wise algorithm if we find any non-ASCII.
1701 */
1702#define STRIDE_LENGTH (2 * sizeof(Vector8))
1703
1704 if (len >= STRIDE_LENGTH)
1705 {
1706 while (len >= STRIDE_LENGTH)
1707 {
1708 /*
1709 * If the chunk is all ASCII, we can skip the full UTF-8 check,
1710 * but we must first check for a non-END state, which means the
1711 * previous chunk ended in the middle of a multibyte sequence.
1712 */
1713 if (state != END || !is_valid_ascii(s, STRIDE_LENGTH))
1715
1716 s += STRIDE_LENGTH;
1717 len -= STRIDE_LENGTH;
1718 }
1719
1720 /* The error state persists, so we only need to check for it here. */
1721 if (state == ERR)
1722 {
1723 /*
1724 * Start over from the beginning with the slow path so we can
1725 * count the valid bytes.
1726 */
1727 len = orig_len;
1728 s = start;
1729 }
1730 else if (state != END)
1731 {
1732 /*
1733 * The fast path exited in the middle of a multibyte sequence.
1734 * Walk backwards to find the leading byte so that the slow path
1735 * can resume checking from there. We must always backtrack at
1736 * least one byte, since the current byte could be e.g. an ASCII
1737 * byte after a 2-byte lead, which is invalid.
1738 */
1739 do
1740 {
1741 Assert(s > start);
1742 s--;
1743 len++;
1745 } while (pg_utf_mblen(s) <= 1);
1746 }
1747 }
1748
1749 /* check remaining bytes */
1750 while (len > 0)
1751 {
1752 int l;
1753
1754 /* fast path for ASCII-subset characters */
1755 if (!IS_HIGHBIT_SET(*s))
1756 {
1757 if (*s == '\0')
1758 break;
1759 l = 1;
1760 }
1761 else
1762 {
1763 l = pg_utf8_verifychar(s, len);
1764 if (l == -1)
1765 break;
1766 }
1767 s += l;
1768 len -= l;
1769 }
1770
1771 return s - start;
1772}
static bool is_valid_ascii(const unsigned char *s, int len)
Definition ascii.h:25
#define pg_utf_mblen
Definition pg_wchar.h:486
#define END
Definition wchar.c:1592
#define ERR
Definition wchar.c:1579
static int pg_utf8_verifychar(const unsigned char *s, int len)
Definition wchar.c:1501
static void utf8_advance(const unsigned char *s, uint32 *state, int len)
Definition wchar.c:1673
#define BGN
Definition wchar.c:1581
#define STRIDE_LENGTH

References Assert, BGN, END, ERR, fb(), IS_HIGHBIT_SET, is_valid_ascii(), len, pg_utf8_verifychar(), pg_utf_mblen, start, STRIDE_LENGTH, and utf8_advance().

◆ pg_utf_dsplen()

static int pg_utf_dsplen ( const unsigned char s)
static

Definition at line 680 of file wchar.c.

681{
682 return ucs_wcwidth(utf8_to_unicode(s));
683}
static char32_t utf8_to_unicode(const unsigned char *c)
Definition mbprint.c:53
static int ucs_wcwidth(pg_wchar ucs)
Definition wchar.c:646

References ucs_wcwidth(), and utf8_to_unicode().

◆ pg_utf_mblen()

int pg_utf_mblen ( const unsigned char s)

Definition at line 556 of file wchar.c.

557{
558 int len;
559
560 if ((*s & 0x80) == 0)
561 len = 1;
562 else if ((*s & 0xe0) == 0xc0)
563 len = 2;
564 else if ((*s & 0xf0) == 0xe0)
565 len = 3;
566 else if ((*s & 0xf8) == 0xf0)
567 len = 4;
568#ifdef NOT_USED
569 else if ((*s & 0xfc) == 0xf8)
570 len = 5;
571 else if ((*s & 0xfe) == 0xfc)
572 len = 6;
573#endif
574 else
575 len = 1;
576 return len;
577}

References len.

◆ pg_wchar2euc_with_len()

static int pg_wchar2euc_with_len ( const pg_wchar from,
unsigned char to,
int  len 
)
static

Definition at line 398 of file wchar.c.

399{
400 int cnt = 0;
401
402 while (len > 0 && *from)
403 {
404 unsigned char c;
405
406 if ((c = (*from >> 24)))
407 {
408 *to++ = c;
409 *to++ = (*from >> 16) & 0xff;
410 *to++ = (*from >> 8) & 0xff;
411 *to++ = *from & 0xff;
412 cnt += 4;
413 }
414 else if ((c = (*from >> 16)))
415 {
416 *to++ = c;
417 *to++ = (*from >> 8) & 0xff;
418 *to++ = *from & 0xff;
419 cnt += 3;
420 }
421 else if ((c = (*from >> 8)))
422 {
423 *to++ = c;
424 *to++ = *from & 0xff;
425 cnt += 2;
426 }
427 else
428 {
429 *to++ = *from;
430 cnt++;
431 }
432 from++;
433 len--;
434 }
435 *to = 0;
436 return cnt;
437}

References len.

◆ pg_wchar2single_with_len()

static int pg_wchar2single_with_len ( const pg_wchar from,
unsigned char to,
int  len 
)
static

Definition at line 711 of file wchar.c.

712{
713 int cnt = 0;
714
715 while (len > 0 && *from)
716 {
717 *to++ = *from++;
718 len--;
719 cnt++;
720 }
721 *to = 0;
722 return cnt;
723}

References len.

◆ pg_wchar2utf_with_len()

static int pg_wchar2utf_with_len ( const pg_wchar from,
unsigned char to,
int  len 
)
static

Definition at line 525 of file wchar.c.

526{
527 int cnt = 0;
528
529 while (len > 0 && *from)
530 {
531 int char_len;
532
533 unicode_to_utf8(*from, to);
535 cnt += char_len;
536 to += char_len;
537 from++;
538 len--;
539 }
540 *to = 0;
541 return cnt;
542}
static unsigned char * unicode_to_utf8(char32_t c, unsigned char *utf8string)
Definition pg_wchar.h:428

References fb(), len, pg_utf_mblen, and unicode_to_utf8().

◆ ucs_wcwidth()

static int ucs_wcwidth ( pg_wchar  ucs)
static

Definition at line 646 of file wchar.c.

647{
650
651 /* test for 8-bit control characters */
652 if (ucs == 0)
653 return 0;
654
655 if (ucs < 0x20 || (ucs >= 0x7f && ucs < 0xa0) || ucs > 0x0010ffff)
656 return -1;
657
658 /*
659 * binary search in table of non-spacing characters
660 *
661 * XXX: In the official Unicode sources, it is possible for a character to
662 * be described as both non-spacing and wide at the same time. As of
663 * Unicode 13.0, treating the non-spacing property as the determining
664 * factor for display width leads to the correct behavior, so do that
665 * search first.
666 */
668 sizeof(nonspacing) / sizeof(struct mbinterval) - 1))
669 return 0;
670
671 /* binary search in table of wide characters */
673 sizeof(east_asian_fw) / sizeof(struct mbinterval) - 1))
674 return 2;
675
676 return 1;
677}
static const struct mbinterval east_asian_fw[]
static const struct mbinterval nonspacing[]
static int mbbisearch(pg_wchar ucs, const struct mbinterval *table, int max)
Definition wchar.c:599

References east_asian_fw, fb(), mbbisearch(), and nonspacing.

Referenced by pg_utf_dsplen().

◆ utf8_advance()

static void utf8_advance ( const unsigned char s,
uint32 state,
int  len 
)
static

Definition at line 1673 of file wchar.c.

1674{
1675 /* Note: We deliberately don't check the state's value here. */
1676 while (len > 0)
1677 {
1678 /*
1679 * It's important that the mask value is 31: In most instruction sets,
1680 * a shift by a 32-bit operand is understood to be a shift by its mod
1681 * 32, so the compiler should elide the mask operation.
1682 */
1683 *state = Utf8Transition[*s++] >> (*state & 31);
1684 len--;
1685 }
1686
1687 *state &= 31;
1688}
static const uint32 Utf8Transition[256]
Definition wchar.c:1615

References len, and Utf8Transition.

Referenced by pg_utf8_verifystr().

Variable Documentation

◆ pg_wchar_table

const pg_wchar_tbl pg_wchar_table[]

Definition at line 1864 of file wchar.c.

1864 {
1906};
@ PG_WIN1254
Definition pg_wchar.h:107
@ PG_LATIN4
Definition pg_wchar.h:87
@ PG_LATIN9
Definition pg_wchar.h:92
@ PG_JOHAB
Definition pg_wchar.h:119
@ PG_KOI8R
Definition pg_wchar.h:98
@ PG_ISO_8859_6
Definition pg_wchar.h:102
@ PG_WIN1253
Definition pg_wchar.h:106
@ PG_KOI8U
Definition pg_wchar.h:110
@ PG_LATIN6
Definition pg_wchar.h:89
@ PG_LATIN5
Definition pg_wchar.h:88
@ PG_EUC_CN
Definition pg_wchar.h:78
@ PG_UHC
Definition pg_wchar.h:117
@ PG_LATIN2
Definition pg_wchar.h:85
@ PG_ISO_8859_5
Definition pg_wchar.h:101
@ PG_LATIN10
Definition pg_wchar.h:93
@ PG_WIN1250
Definition pg_wchar.h:105
@ PG_ISO_8859_7
Definition pg_wchar.h:103
@ PG_SJIS
Definition pg_wchar.h:114
@ PG_LATIN8
Definition pg_wchar.h:91
@ PG_EUC_JP
Definition pg_wchar.h:77
@ PG_GBK
Definition pg_wchar.h:116
@ PG_LATIN3
Definition pg_wchar.h:86
@ PG_WIN1256
Definition pg_wchar.h:94
@ PG_LATIN1
Definition pg_wchar.h:84
@ PG_EUC_TW
Definition pg_wchar.h:80
@ PG_WIN1258
Definition pg_wchar.h:95
@ PG_SHIFT_JIS_2004
Definition pg_wchar.h:120
@ PG_WIN1252
Definition pg_wchar.h:100
@ PG_LATIN7
Definition pg_wchar.h:90
@ PG_WIN1255
Definition pg_wchar.h:108
@ PG_WIN1257
Definition pg_wchar.h:109
@ PG_WIN1251
Definition pg_wchar.h:99
@ PG_EUC_KR
Definition pg_wchar.h:79
@ PG_WIN866
Definition pg_wchar.h:96
@ PG_ISO_8859_8
Definition pg_wchar.h:104
@ PG_WIN874
Definition pg_wchar.h:97
@ PG_EUC_JIS_2004
Definition pg_wchar.h:81
@ PG_BIG5
Definition pg_wchar.h:115
static int pg_uhc_verifystr(const unsigned char *s, int len)
Definition wchar.c:1412
static int pg_latin1_dsplen(const unsigned char *s)
Definition wchar.c:732
static int pg_euctw_mblen(const unsigned char *s)
Definition wchar.c:360
static int pg_euckr_dsplen(const unsigned char *s)
Definition wchar.c:227
static int pg_ascii_verifystr(const unsigned char *s, int len)
Definition wchar.c:919
static int pg_latin1_verifychar(const unsigned char *s, int len)
Definition wchar.c:1210
static int pg_sjis_dsplen(const unsigned char *s)
Definition wchar.c:755
static int pg_eucjp_dsplen(const unsigned char *s)
Definition wchar.c:196
static int pg_ascii2wchar_with_len(const unsigned char *from, pg_wchar *to, int len)
Definition wchar.c:73
static int pg_gbk_dsplen(const unsigned char *s)
Definition wchar.c:811
static int pg_euckr2wchar_with_len(const unsigned char *from, pg_wchar *to, int len)
Definition wchar.c:215
static int pg_euctw2wchar_with_len(const unsigned char *from, pg_wchar *to, int len)
Definition wchar.c:317
#define pg_euccn_verifychar
Definition wchar.c:1074
static int pg_sjis_verifystr(const unsigned char *s, int len)
Definition wchar.c:1250
static int pg_johab_dsplen(const unsigned char *s)
Definition wchar.c:450
static int pg_big5_verifystr(const unsigned char *s, int len)
Definition wchar.c:1304
static int pg_eucjp2wchar_with_len(const unsigned char *from, pg_wchar *to, int len)
Definition wchar.c:184
static int pg_latin1_verifystr(const unsigned char *s, int len)
Definition wchar.c:1216
static int pg_latin1_mblen(const unsigned char *s)
Definition wchar.c:726
static int pg_ascii_verifychar(const unsigned char *s, int len)
Definition wchar.c:913
static int pg_ascii_mblen(const unsigned char *s)
Definition wchar.c:88
static int pg_big5_dsplen(const unsigned char *s)
Definition wchar.c:784
#define pg_euccn_verifystr
Definition wchar.c:1075
static int pg_eucjp_mblen(const unsigned char *s)
Definition wchar.c:190
static int pg_euccn_dsplen(const unsigned char *s)
Definition wchar.c:301
static int pg_euctw_verifystr(const unsigned char *s, int len)
Definition wchar.c:1128
static int pg_gbk_verifystr(const unsigned char *s, int len)
Definition wchar.c:1358
static int pg_gb18030_dsplen(const unsigned char *s)
Definition wchar.c:879
static int pg_utf2wchar_with_len(const unsigned char *from, pg_wchar *to, int len)
Definition wchar.c:462
static int pg_euccn_mblen(const unsigned char *s)
Definition wchar.c:285
static int pg_eucjp_verifystr(const unsigned char *s, int len)
Definition wchar.c:987
static int pg_johab_verifystr(const unsigned char *s, int len)
Definition wchar.c:1181
static int pg_gb18030_verifystr(const unsigned char *s, int len)
Definition wchar.c:1472
static int pg_euckr_verifystr(const unsigned char *s, int len)
Definition wchar.c:1045
static int pg_uhc_dsplen(const unsigned char *s)
Definition wchar.c:838
static int pg_wchar2euc_with_len(const pg_wchar *from, unsigned char *to, int len)
Definition wchar.c:398
static int pg_wchar2single_with_len(const pg_wchar *from, unsigned char *to, int len)
Definition wchar.c:711
static int pg_wchar2utf_with_len(const pg_wchar *from, unsigned char *to, int len)
Definition wchar.c:525
static int pg_euccn2wchar_with_len(const unsigned char *from, pg_wchar *to, int len)
Definition wchar.c:237
static int pg_gb18030_mblen(const unsigned char *s)
Definition wchar.c:865
static int pg_euctw_dsplen(const unsigned char *s)
Definition wchar.c:376
static int pg_latin12wchar_with_len(const unsigned char *from, pg_wchar *to, int len)
Definition wchar.c:689
static int pg_utf8_verifystr(const unsigned char *s, int len)
Definition wchar.c:1691
static int pg_euckr_mblen(const unsigned char *s)
Definition wchar.c:221
static int pg_utf_dsplen(const unsigned char *s)
Definition wchar.c:680

Referenced by pg_database_encoding_max_length(), pg_dsplen(), pg_encoding_dsplen(), pg_encoding_max_length(), pg_encoding_max_length_sql(), pg_encoding_mb2wchar_with_len(), pg_encoding_mbcliplen(), pg_encoding_mblen(), pg_encoding_verifymbchar(), pg_encoding_verifymbstr(), pg_encoding_wchar2mb_with_len(), pg_generic_charinc(), pg_mb2wchar(), pg_mb2wchar_with_len(), pg_mblen_cstr(), pg_mblen_range(), pg_mblen_unbounded(), pg_mblen_with_len(), pg_verify_mbstr(), pg_verify_mbstr_len(), pg_wchar2mb(), and pg_wchar2mb_with_len().

◆ Utf8Transition

const uint32 Utf8Transition[256]
static

Definition at line 1615 of file wchar.c.

1616{
1617 /* ASCII */
1618
1619 ILL, ASC, ASC, ASC, ASC, ASC, ASC, ASC,
1620 ASC, ASC, ASC, ASC, ASC, ASC, ASC, ASC,
1621 ASC, ASC, ASC, ASC, ASC, ASC, ASC, ASC,
1622 ASC, ASC, ASC, ASC, ASC, ASC, ASC, ASC,
1623
1624 ASC, ASC, ASC, ASC, ASC, ASC, ASC, ASC,
1625 ASC, ASC, ASC, ASC, ASC, ASC, ASC, ASC,
1626 ASC, ASC, ASC, ASC, ASC, ASC, ASC, ASC,
1627 ASC, ASC, ASC, ASC, ASC, ASC, ASC, ASC,
1628
1629 ASC, ASC, ASC, ASC, ASC, ASC, ASC, ASC,
1630 ASC, ASC, ASC, ASC, ASC, ASC, ASC, ASC,
1631 ASC, ASC, ASC, ASC, ASC, ASC, ASC, ASC,
1632 ASC, ASC, ASC, ASC, ASC, ASC, ASC, ASC,
1633
1634 ASC, ASC, ASC, ASC, ASC, ASC, ASC, ASC,
1635 ASC, ASC, ASC, ASC, ASC, ASC, ASC, ASC,
1636 ASC, ASC, ASC, ASC, ASC, ASC, ASC, ASC,
1637 ASC, ASC, ASC, ASC, ASC, ASC, ASC, ASC,
1638
1639 /* continuation bytes */
1640
1641 /* 80..8F */
1642 CR1, CR1, CR1, CR1, CR1, CR1, CR1, CR1,
1643 CR1, CR1, CR1, CR1, CR1, CR1, CR1, CR1,
1644
1645 /* 90..9F */
1646 CR2, CR2, CR2, CR2, CR2, CR2, CR2, CR2,
1647 CR2, CR2, CR2, CR2, CR2, CR2, CR2, CR2,
1648
1649 /* A0..BF */
1650 CR3, CR3, CR3, CR3, CR3, CR3, CR3, CR3,
1651 CR3, CR3, CR3, CR3, CR3, CR3, CR3, CR3,
1652 CR3, CR3, CR3, CR3, CR3, CR3, CR3, CR3,
1653 CR3, CR3, CR3, CR3, CR3, CR3, CR3, CR3,
1654
1655 /* leading bytes */
1656
1657 /* C0..DF */
1658 ILL, ILL, L2A, L2A, L2A, L2A, L2A, L2A,
1659 L2A, L2A, L2A, L2A, L2A, L2A, L2A, L2A,
1660 L2A, L2A, L2A, L2A, L2A, L2A, L2A, L2A,
1661 L2A, L2A, L2A, L2A, L2A, L2A, L2A, L2A,
1662
1663 /* E0..EF */
1664 L3A, L3B, L3B, L3B, L3B, L3B, L3B, L3B,
1665 L3B, L3B, L3B, L3B, L3B, L3C, L3B, L3B,
1666
1667 /* F0..FF */
1668 L4A, L4B, L4B, L4B, L4C, ILL, ILL, ILL,
1669 ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL
1670};
#define CR3
Definition wchar.c:1611
#define L3B
Definition wchar.c:1602
#define L2A
Definition wchar.c:1599
#define L4C
Definition wchar.c:1607
#define CR2
Definition wchar.c:1610
#define ASC
Definition wchar.c:1597
#define L3C
Definition wchar.c:1603
#define CR1
Definition wchar.c:1609
#define L3A
Definition wchar.c:1601
#define L4B
Definition wchar.c:1606
#define ILL
Definition wchar.c:1613
#define L4A
Definition wchar.c:1605

Referenced by utf8_advance().