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 1598 of file wchar.c.

◆ BGN

#define BGN   11

Definition at line 1582 of file wchar.c.

◆ CR1

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

Definition at line 1610 of file wchar.c.

◆ CR2

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

Definition at line 1611 of file wchar.c.

◆ CR3

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

Definition at line 1612 of file wchar.c.

◆ CS1

#define CS1   16

Definition at line 1584 of file wchar.c.

◆ CS2

#define CS2   1

Definition at line 1585 of file wchar.c.

◆ CS3

#define CS3   5

Definition at line 1586 of file wchar.c.

◆ END

#define END   BGN

Definition at line 1593 of file wchar.c.

◆ ERR

#define ERR   0

Definition at line 1580 of file wchar.c.

◆ ILL

#define ILL   ERR

Definition at line 1614 of file wchar.c.

◆ IS_EUC_RANGE_VALID

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

Definition at line 930 of file wchar.c.

◆ L2A

#define L2A   (CS1 << BGN)

Definition at line 1600 of file wchar.c.

◆ L3A

#define L3A   (P3A << BGN)

Definition at line 1602 of file wchar.c.

◆ L3B

#define L3B   (CS2 << BGN)

Definition at line 1603 of file wchar.c.

◆ L3C

#define L3C   (P3B << BGN)

Definition at line 1604 of file wchar.c.

◆ L4A

#define L4A   (P4A << BGN)

Definition at line 1606 of file wchar.c.

◆ L4B

#define L4B   (CS3 << BGN)

Definition at line 1607 of file wchar.c.

◆ L4C

#define L4C   (P4B << BGN)

Definition at line 1608 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 1588 of file wchar.c.

◆ P3B

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

Definition at line 1589 of file wchar.c.

◆ P4A

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

Definition at line 1590 of file wchar.c.

◆ P4B

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

Definition at line 1591 of file wchar.c.

◆ pg_euccn_verifychar

#define pg_euccn_verifychar   pg_euckr_verifychar

Definition at line 1075 of file wchar.c.

◆ pg_euccn_verifystr

#define pg_euccn_verifystr   pg_euckr_verifystr

Definition at line 1076 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 914 of file wchar.c.

915{
916 return 1;
917}

◆ pg_ascii_verifystr()

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

Definition at line 920 of file wchar.c.

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

References fb(), and len.

◆ pg_big5_dsplen()

static int pg_big5_dsplen ( const unsigned char s)
static

Definition at line 785 of file wchar.c.

786{
787 int len;
788
789 if (IS_HIGHBIT_SET(*s))
790 len = 2; /* kanji? */
791 else
792 len = pg_ascii_dsplen(s); /* should be ASCII */
793 return len;
794}
#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 773 of file wchar.c.

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

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 1280 of file wchar.c.

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

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

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 1976 of file wchar.c.

1977{
1978 return (PG_VALID_ENCODING(encoding) ?
1979 pg_wchar_table[encoding].dsplen((const unsigned char *) mbstr) :
1981}
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:1865

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 2013 of file wchar.c.

2014{
2016
2017 /*
2018 * Check for the encoding despite the assert, due to some mingw versions
2019 * otherwise issuing bogus warnings.
2020 */
2021 return PG_VALID_ENCODING(encoding) ?
2024}
#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 1967 of file wchar.c.

1968{
1970}
int pg_encoding_mblen(int encoding, const char *mbstr)
Definition wchar.c:1935

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 1947 of file wchar.c.

1949{
1950 /*
1951 * Define zero remaining as too few, even for single-byte encodings.
1952 * pg_gb18030_mblen() reads one or two bytes; single-byte encodings read
1953 * zero; others read one.
1954 */
1955 if (remaining < 1 ||
1957 return INT_MAX;
1959}
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 1852 of file wchar.c.

1853{
1855
1856 dst[0] = (encoding == PG_UTF8 ? 0xc0 : NONUTF8_INVALID_BYTE0);
1858}
#define PG_UTF8
Definition mbprint.c:43
int pg_encoding_max_length(int encoding)
Definition wchar.c:2013

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 933 of file wchar.c.

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

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 988 of file wchar.c.

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

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 1017 of file wchar.c.

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

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 1046 of file wchar.c.

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

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 1079 of file wchar.c.

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

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 1129 of file wchar.c.

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

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 880 of file wchar.c.

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

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 866 of file wchar.c.

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

References IS_HIGHBIT_SET, and len.

◆ pg_gb18030_verifychar()

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

Definition at line 1442 of file wchar.c.

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

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 1473 of file wchar.c.

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

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 812 of file wchar.c.

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

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 800 of file wchar.c.

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

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 1334 of file wchar.c.

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

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 1359 of file wchar.c.

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

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 1158 of file wchar.c.

1159{
1160 int l,
1161 mbl;
1162 unsigned char c;
1163
1164 l = mbl = pg_johab_mblen(s);
1165
1166 if (len < l)
1167 return -1;
1168
1169 if (!IS_HIGHBIT_SET(*s))
1170 return mbl;
1171
1172 while (--l > 0)
1173 {
1174 c = *++s;
1175 if (!IS_EUC_RANGE_VALID(c))
1176 return -1;
1177 }
1178 return mbl;
1179}
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 1182 of file wchar.c.

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

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 690 of file wchar.c.

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

References len.

◆ pg_latin1_dsplen()

static int pg_latin1_dsplen ( const unsigned char s)
static

Definition at line 733 of file wchar.c.

734{
735 return pg_ascii_dsplen(s);
736}

References pg_ascii_dsplen().

◆ pg_latin1_mblen()

static int pg_latin1_mblen ( const unsigned char s)
static

Definition at line 727 of file wchar.c.

728{
729 return 1;
730}

◆ pg_latin1_verifychar()

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

Definition at line 1211 of file wchar.c.

1212{
1213 return 1;
1214}

◆ pg_latin1_verifystr()

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

Definition at line 1217 of file wchar.c.

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

References fb(), and len.

◆ pg_sjis_dsplen()

static int pg_sjis_dsplen ( const unsigned char s)
static

Definition at line 756 of file wchar.c.

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

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 742 of file wchar.c.

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

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 1228 of file wchar.c.

1229{
1230 int l,
1231 mbl;
1232 unsigned char c1,
1233 c2;
1234
1235 l = mbl = pg_sjis_mblen(s);
1236
1237 if (len < l)
1238 return -1;
1239
1240 if (l == 1) /* pg_sjis_mblen already verified it */
1241 return mbl;
1242
1243 c1 = *s++;
1244 c2 = *s;
1245 if (!ISSJISHEAD(c1) || !ISSJISTAIL(c2))
1246 return -1;
1247 return mbl;
1248}
#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:742

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 1251 of file wchar.c.

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

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 839 of file wchar.c.

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

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 827 of file wchar.c.

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

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 1388 of file wchar.c.

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

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 1413 of file wchar.c.

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

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 1790 of file wchar.c.

1791{
1792 unsigned char a;
1793
1794 switch (length)
1795 {
1796 default:
1797 /* reject lengths 5 and 6 for now */
1798 return false;
1799 case 4:
1800 a = source[3];
1801 if (a < 0x80 || a > 0xBF)
1802 return false;
1804 case 3:
1805 a = source[2];
1806 if (a < 0x80 || a > 0xBF)
1807 return false;
1809 case 2:
1810 a = source[1];
1811 switch (*source)
1812 {
1813 case 0xE0:
1814 if (a < 0xA0 || a > 0xBF)
1815 return false;
1816 break;
1817 case 0xED:
1818 if (a < 0x80 || a > 0x9F)
1819 return false;
1820 break;
1821 case 0xF0:
1822 if (a < 0x90 || a > 0xBF)
1823 return false;
1824 break;
1825 case 0xF4:
1826 if (a < 0x80 || a > 0x8F)
1827 return false;
1828 break;
1829 default:
1830 if (a < 0x80 || a > 0xBF)
1831 return false;
1832 break;
1833 }
1835 case 1:
1836 a = *source;
1837 if (a >= 0x80 && a < 0xC2)
1838 return false;
1839 if (a > 0xF4)
1840 return false;
1841 break;
1842 }
1843 return true;
1844}
#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 1502 of file wchar.c.

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

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 1692 of file wchar.c.

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

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

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 712 of file wchar.c.

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

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 647 of file wchar.c.

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

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

References len, and Utf8Transition.

Referenced by pg_utf8_verifystr().

Variable Documentation

◆ pg_wchar_table

const pg_wchar_tbl pg_wchar_table[]

Definition at line 1865 of file wchar.c.

1865 {
1907};
@ 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:1413
static int pg_latin1_dsplen(const unsigned char *s)
Definition wchar.c:733
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:920
static int pg_latin1_verifychar(const unsigned char *s, int len)
Definition wchar.c:1211
static int pg_sjis_dsplen(const unsigned char *s)
Definition wchar.c:756
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:812
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:1075
static int pg_sjis_verifystr(const unsigned char *s, int len)
Definition wchar.c:1251
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:1305
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:1217
static int pg_latin1_mblen(const unsigned char *s)
Definition wchar.c:727
static int pg_ascii_verifychar(const unsigned char *s, int len)
Definition wchar.c:914
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:785
#define pg_euccn_verifystr
Definition wchar.c:1076
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:1129
static int pg_gbk_verifystr(const unsigned char *s, int len)
Definition wchar.c:1359
static int pg_gb18030_dsplen(const unsigned char *s)
Definition wchar.c:880
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:988
static int pg_johab_verifystr(const unsigned char *s, int len)
Definition wchar.c:1182
static int pg_gb18030_verifystr(const unsigned char *s, int len)
Definition wchar.c:1473
static int pg_euckr_verifystr(const unsigned char *s, int len)
Definition wchar.c:1046
static int pg_uhc_dsplen(const unsigned char *s)
Definition wchar.c:839
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:712
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:866
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:690
static int pg_utf8_verifystr(const unsigned char *s, int len)
Definition wchar.c:1692
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:681

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 1616 of file wchar.c.

1617{
1618 /* ASCII */
1619
1620 ILL, 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 ASC, ASC, ASC, ASC, ASC, ASC, ASC, ASC,
1624
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 ASC, ASC, ASC, ASC, ASC, ASC, ASC, ASC,
1629
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 ASC, ASC, ASC, ASC, ASC, ASC, ASC, ASC,
1634
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 ASC, ASC, ASC, ASC, ASC, ASC, ASC, ASC,
1639
1640 /* continuation bytes */
1641
1642 /* 80..8F */
1643 CR1, CR1, CR1, CR1, CR1, CR1, CR1, CR1,
1644 CR1, CR1, CR1, CR1, CR1, CR1, CR1, CR1,
1645
1646 /* 90..9F */
1647 CR2, CR2, CR2, CR2, CR2, CR2, CR2, CR2,
1648 CR2, CR2, CR2, CR2, CR2, CR2, CR2, CR2,
1649
1650 /* A0..BF */
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 CR3, CR3, CR3, CR3, CR3, CR3, CR3, CR3,
1655
1656 /* leading bytes */
1657
1658 /* C0..DF */
1659 ILL, ILL, 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 L2A, L2A, L2A, L2A, L2A, L2A, L2A, L2A,
1663
1664 /* E0..EF */
1665 L3A, L3B, L3B, L3B, L3B, L3B, L3B, L3B,
1666 L3B, L3B, L3B, L3B, L3B, L3C, L3B, L3B,
1667
1668 /* F0..FF */
1669 L4A, L4B, L4B, L4B, L4C, ILL, ILL, ILL,
1670 ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL
1671};
#define CR3
Definition wchar.c:1612
#define L3B
Definition wchar.c:1603
#define L2A
Definition wchar.c:1600
#define L4C
Definition wchar.c:1608
#define CR2
Definition wchar.c:1611
#define ASC
Definition wchar.c:1598
#define L3C
Definition wchar.c:1604
#define CR1
Definition wchar.c:1610
#define L3A
Definition wchar.c:1602
#define L4B
Definition wchar.c:1607
#define ILL
Definition wchar.c:1614
#define L4A
Definition wchar.c:1606

Referenced by utf8_advance().