1 /*------------------------------------------------------------------------- 2 * 3 * pg_wchar.h 4 * multibyte-character support 5 * 6 * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group 7 * Portions Copyright (c) 1994, Regents of the University of California 8 * 9 * src/include/mb/pg_wchar.h 10 * 11 * NOTES 12 * This is used both by the backend and by libpq, but should not be 13 * included by libpq client programs. In particular, a libpq client 14 * should not assume that the encoding IDs used by the version of libpq 15 * it's linked to match up with the IDs declared here. 16 * 17 *------------------------------------------------------------------------- 18 */ 19 #ifndef PG_WCHAR_H 20 #define PG_WCHAR_H 21 22 /* 23 * The pg_wchar type 24 */ 25 typedef unsigned int pg_wchar; 26 27 /* 28 * Maximum byte length of multibyte characters in any backend encoding 29 */ 30 #define MAX_MULTIBYTE_CHAR_LEN 4 31 32 /* 33 * various definitions for EUC 34 */ 35 #define SS2 0x8e /* single shift 2 (JIS0201) */ 36 #define SS3 0x8f /* single shift 3 (JIS0212) */ 37 38 /* 39 * SJIS validation macros 40 */ 41 #define ISSJISHEAD(c) (((c) >= 0x81 && (c) <= 0x9f) || ((c) >= 0xe0 && (c) <= 0xfc)) 42 #define ISSJISTAIL(c) (((c) >= 0x40 && (c) <= 0x7e) || ((c) >= 0x80 && (c) <= 0xfc)) 43 44 /*---------------------------------------------------- 45 * MULE Internal Encoding (MIC) 46 * 47 * This encoding follows the design used within XEmacs; it is meant to 48 * subsume many externally-defined character sets. Each character includes 49 * identification of the character set it belongs to, so the encoding is 50 * general but somewhat bulky. 51 * 52 * Currently PostgreSQL supports 5 types of MULE character sets: 53 * 54 * 1) 1-byte ASCII characters. Each byte is below 0x80. 55 * 56 * 2) "Official" single byte charsets such as ISO-8859-1 (Latin1). 57 * Each MULE character consists of 2 bytes: LC1 + C1, where LC1 is 58 * an identifier for the charset (in the range 0x81 to 0x8d) and C1 59 * is the character code (in the range 0xa0 to 0xff). 60 * 61 * 3) "Private" single byte charsets such as SISHENG. Each MULE 62 * character consists of 3 bytes: LCPRV1 + LC12 + C1, where LCPRV1 63 * is a private-charset flag, LC12 is an identifier for the charset, 64 * and C1 is the character code (in the range 0xa0 to 0xff). 65 * LCPRV1 is either 0x9a (if LC12 is in the range 0xa0 to 0xdf) 66 * or 0x9b (if LC12 is in the range 0xe0 to 0xef). 67 * 68 * 4) "Official" multibyte charsets such as JIS X0208. Each MULE 69 * character consists of 3 bytes: LC2 + C1 + C2, where LC2 is 70 * an identifier for the charset (in the range 0x90 to 0x99) and C1 71 * and C2 form the character code (each in the range 0xa0 to 0xff). 72 * 73 * 5) "Private" multibyte charsets such as CNS 11643-1992 Plane 3. 74 * Each MULE character consists of 4 bytes: LCPRV2 + LC22 + C1 + C2, 75 * where LCPRV2 is a private-charset flag, LC22 is an identifier for 76 * the charset, and C1 and C2 form the character code (each in the range 77 * 0xa0 to 0xff). LCPRV2 is either 0x9c (if LC22 is in the range 0xf0 78 * to 0xf4) or 0x9d (if LC22 is in the range 0xf5 to 0xfe). 79 * 80 * "Official" encodings are those that have been assigned code numbers by 81 * the XEmacs project; "private" encodings have Postgres-specific charset 82 * identifiers. 83 * 84 * See the "XEmacs Internals Manual", available at http://www.xemacs.org, 85 * for more details. Note that for historical reasons, Postgres' 86 * private-charset flag values do not match what XEmacs says they should be, 87 * so this isn't really exactly MULE (not that private charsets would be 88 * interoperable anyway). 89 * 90 * Note that XEmacs's implementation is different from what emacs does. 91 * We follow emacs's implementation, rather than XEmacs's. 92 *---------------------------------------------------- 93 */ 94 95 /* 96 * Charset identifiers (also called "leading bytes" in the MULE documentation) 97 */ 98 99 /* 100 * Charset IDs for official single byte encodings (0x81-0x8e) 101 */ 102 #define LC_ISO8859_1 0x81 /* ISO8859 Latin 1 */ 103 #define LC_ISO8859_2 0x82 /* ISO8859 Latin 2 */ 104 #define LC_ISO8859_3 0x83 /* ISO8859 Latin 3 */ 105 #define LC_ISO8859_4 0x84 /* ISO8859 Latin 4 */ 106 #define LC_TIS620 0x85 /* Thai (not supported yet) */ 107 #define LC_ISO8859_7 0x86 /* Greek (not supported yet) */ 108 #define LC_ISO8859_6 0x87 /* Arabic (not supported yet) */ 109 #define LC_ISO8859_8 0x88 /* Hebrew (not supported yet) */ 110 #define LC_JISX0201K 0x89 /* Japanese 1 byte kana */ 111 #define LC_JISX0201R 0x8a /* Japanese 1 byte Roman */ 112 /* Note that 0x8b seems to be unused as of Emacs 20.7. 113 * However, there might be a chance that 0x8b could be used 114 * in later versions of Emacs. 115 */ 116 #define LC_KOI8_R 0x8b /* Cyrillic KOI8-R */ 117 #define LC_ISO8859_5 0x8c /* ISO8859 Cyrillic */ 118 #define LC_ISO8859_9 0x8d /* ISO8859 Latin 5 (not supported yet) */ 119 #define LC_ISO8859_15 0x8e /* ISO8859 Latin 15 (not supported yet) */ 120 /* #define CONTROL_1 0x8f control characters (unused) */ 121 122 /* Is a leading byte for "official" single byte encodings? */ 123 #define IS_LC1(c) ((unsigned char)(c) >= 0x81 && (unsigned char)(c) <= 0x8d) 124 125 /* 126 * Charset IDs for official multibyte encodings (0x90-0x99) 127 * 0x9a-0x9d are free. 0x9e and 0x9f are reserved. 128 */ 129 #define LC_JISX0208_1978 0x90 /* Japanese Kanji, old JIS (not supported) */ 130 #define LC_GB2312_80 0x91 /* Chinese */ 131 #define LC_JISX0208 0x92 /* Japanese Kanji (JIS X 0208) */ 132 #define LC_KS5601 0x93 /* Korean */ 133 #define LC_JISX0212 0x94 /* Japanese Kanji (JIS X 0212) */ 134 #define LC_CNS11643_1 0x95 /* CNS 11643-1992 Plane 1 */ 135 #define LC_CNS11643_2 0x96 /* CNS 11643-1992 Plane 2 */ 136 #define LC_JISX0213_1 0x97/* Japanese Kanji (JIS X 0213 Plane 1) (not 137 * supported) */ 138 #define LC_BIG5_1 0x98 /* Plane 1 Chinese traditional (not supported) */ 139 #define LC_BIG5_2 0x99 /* Plane 1 Chinese traditional (not supported) */ 140 141 /* Is a leading byte for "official" multibyte encodings? */ 142 #define IS_LC2(c) ((unsigned char)(c) >= 0x90 && (unsigned char)(c) <= 0x99) 143 144 /* 145 * Postgres-specific prefix bytes for "private" single byte encodings 146 * (According to the MULE docs, we should be using 0x9e for this) 147 */ 148 #define LCPRV1_A 0x9a 149 #define LCPRV1_B 0x9b 150 #define IS_LCPRV1(c) ((unsigned char)(c) == LCPRV1_A || (unsigned char)(c) == LCPRV1_B) 151 #define IS_LCPRV1_A_RANGE(c) \ 152 ((unsigned char)(c) >= 0xa0 && (unsigned char)(c) <= 0xdf) 153 #define IS_LCPRV1_B_RANGE(c) \ 154 ((unsigned char)(c) >= 0xe0 && (unsigned char)(c) <= 0xef) 155 156 /* 157 * Postgres-specific prefix bytes for "private" multibyte encodings 158 * (According to the MULE docs, we should be using 0x9f for this) 159 */ 160 #define LCPRV2_A 0x9c 161 #define LCPRV2_B 0x9d 162 #define IS_LCPRV2(c) ((unsigned char)(c) == LCPRV2_A || (unsigned char)(c) == LCPRV2_B) 163 #define IS_LCPRV2_A_RANGE(c) \ 164 ((unsigned char)(c) >= 0xf0 && (unsigned char)(c) <= 0xf4) 165 #define IS_LCPRV2_B_RANGE(c) \ 166 ((unsigned char)(c) >= 0xf5 && (unsigned char)(c) <= 0xfe) 167 168 /* 169 * Charset IDs for private single byte encodings (0xa0-0xef) 170 */ 171 #define LC_SISHENG 0xa0/* Chinese SiSheng characters for 172 * PinYin/ZhuYin (not supported) */ 173 #define LC_IPA 0xa1/* IPA (International Phonetic Association) 174 * (not supported) */ 175 #define LC_VISCII_LOWER 0xa2/* Vietnamese VISCII1.1 lower-case (not 176 * supported) */ 177 #define LC_VISCII_UPPER 0xa3/* Vietnamese VISCII1.1 upper-case (not 178 * supported) */ 179 #define LC_ARABIC_DIGIT 0xa4 /* Arabic digit (not supported) */ 180 #define LC_ARABIC_1_COLUMN 0xa5 /* Arabic 1-column (not supported) */ 181 #define LC_ASCII_RIGHT_TO_LEFT 0xa6 /* ASCII (left half of ISO8859-1) with 182 * right-to-left direction (not 183 * supported) */ 184 #define LC_LAO 0xa7/* Lao characters (ISO10646 0E80..0EDF) (not 185 * supported) */ 186 #define LC_ARABIC_2_COLUMN 0xa8 /* Arabic 1-column (not supported) */ 187 188 /* 189 * Charset IDs for private multibyte encodings (0xf0-0xff) 190 */ 191 #define LC_INDIAN_1_COLUMN 0xf0/* Indian charset for 1-column width glyphs 192 * (not supported) */ 193 #define LC_TIBETAN_1_COLUMN 0xf1/* Tibetan 1-column width glyphs (not 194 * supported) */ 195 #define LC_UNICODE_SUBSET_2 0xf2/* Unicode characters of the range 196 * U+2500..U+33FF. (not supported) */ 197 #define LC_UNICODE_SUBSET_3 0xf3/* Unicode characters of the range 198 * U+E000..U+FFFF. (not supported) */ 199 #define LC_UNICODE_SUBSET 0xf4/* Unicode characters of the range 200 * U+0100..U+24FF. (not supported) */ 201 #define LC_ETHIOPIC 0xf5 /* Ethiopic characters (not supported) */ 202 #define LC_CNS11643_3 0xf6 /* CNS 11643-1992 Plane 3 */ 203 #define LC_CNS11643_4 0xf7 /* CNS 11643-1992 Plane 4 */ 204 #define LC_CNS11643_5 0xf8 /* CNS 11643-1992 Plane 5 */ 205 #define LC_CNS11643_6 0xf9 /* CNS 11643-1992 Plane 6 */ 206 #define LC_CNS11643_7 0xfa /* CNS 11643-1992 Plane 7 */ 207 #define LC_INDIAN_2_COLUMN 0xfb/* Indian charset for 2-column width glyphs 208 * (not supported) */ 209 #define LC_TIBETAN 0xfc /* Tibetan (not supported) */ 210 /* #define FREE 0xfd free (unused) */ 211 /* #define FREE 0xfe free (unused) */ 212 /* #define FREE 0xff free (unused) */ 213 214 /*---------------------------------------------------- 215 * end of MULE stuff 216 *---------------------------------------------------- 217 */ 218 219 /* 220 * PostgreSQL encoding identifiers 221 * 222 * WARNING: the order of this enum must be same as order of entries 223 * in the pg_enc2name_tbl[] array (in mb/encnames.c), and 224 * in the pg_wchar_table[] array (in mb/wchar.c)! 225 * 226 * If you add some encoding don't forget to check 227 * PG_ENCODING_BE_LAST macro. 228 * 229 * PG_SQL_ASCII is default encoding and must be = 0. 230 * 231 * XXX We must avoid renumbering any backend encoding until libpq's major 232 * version number is increased beyond 5; it turns out that the backend 233 * encoding IDs are effectively part of libpq's ABI as far as 8.2 initdb and 234 * psql are concerned. 235 */ 236 typedef enum pg_enc 237 { 238 PG_SQL_ASCII = 0, /* SQL/ASCII */ 239 PG_EUC_JP, /* EUC for Japanese */ 240 PG_EUC_CN, /* EUC for Chinese */ 241 PG_EUC_KR, /* EUC for Korean */ 242 PG_EUC_TW, /* EUC for Taiwan */ 243 PG_EUC_JIS_2004, /* EUC-JIS-2004 */ 244 PG_UTF8, /* Unicode UTF8 */ 245 PG_MULE_INTERNAL, /* Mule internal code */ 246 PG_LATIN1, /* ISO-8859-1 Latin 1 */ 247 PG_LATIN2, /* ISO-8859-2 Latin 2 */ 248 PG_LATIN3, /* ISO-8859-3 Latin 3 */ 249 PG_LATIN4, /* ISO-8859-4 Latin 4 */ 250 PG_LATIN5, /* ISO-8859-9 Latin 5 */ 251 PG_LATIN6, /* ISO-8859-10 Latin6 */ 252 PG_LATIN7, /* ISO-8859-13 Latin7 */ 253 PG_LATIN8, /* ISO-8859-14 Latin8 */ 254 PG_LATIN9, /* ISO-8859-15 Latin9 */ 255 PG_LATIN10, /* ISO-8859-16 Latin10 */ 256 PG_WIN1256, /* windows-1256 */ 257 PG_WIN1258, /* Windows-1258 */ 258 PG_WIN866, /* (MS-DOS CP866) */ 259 PG_WIN874, /* windows-874 */ 260 PG_KOI8R, /* KOI8-R */ 261 PG_WIN1251, /* windows-1251 */ 262 PG_WIN1252, /* windows-1252 */ 263 PG_ISO_8859_5, /* ISO-8859-5 */ 264 PG_ISO_8859_6, /* ISO-8859-6 */ 265 PG_ISO_8859_7, /* ISO-8859-7 */ 266 PG_ISO_8859_8, /* ISO-8859-8 */ 267 PG_WIN1250, /* windows-1250 */ 268 PG_WIN1253, /* windows-1253 */ 269 PG_WIN1254, /* windows-1254 */ 270 PG_WIN1255, /* windows-1255 */ 271 PG_WIN1257, /* windows-1257 */ 272 PG_KOI8U, /* KOI8-U */ 273 /* PG_ENCODING_BE_LAST points to the above entry */ 274 275 /* followings are for client encoding only */ 276 PG_SJIS, /* Shift JIS (Windows-932) */ 277 PG_BIG5, /* Big5 (Windows-950) */ 278 PG_GBK, /* GBK (Windows-936) */ 279 PG_UHC, /* UHC (Windows-949) */ 280 PG_GB18030, /* GB18030 */ 281 PG_JOHAB, /* EUC for Korean JOHAB */ 282 PG_SHIFT_JIS_2004, /* Shift-JIS-2004 */ 283 _PG_LAST_ENCODING_ /* mark only */ 284 285 } pg_enc; 286 287 #define PG_ENCODING_BE_LAST PG_KOI8U 288 289 /* 290 * Please use these tests before access to pg_encconv_tbl[] 291 * or to other places... 292 */ 293 #define PG_VALID_BE_ENCODING(_enc) \ 294 ((_enc) >= 0 && (_enc) <= PG_ENCODING_BE_LAST) 295 296 #define PG_ENCODING_IS_CLIENT_ONLY(_enc) \ 297 ((_enc) > PG_ENCODING_BE_LAST && (_enc) < _PG_LAST_ENCODING_) 298 299 #define PG_VALID_ENCODING(_enc) \ 300 ((_enc) >= 0 && (_enc) < _PG_LAST_ENCODING_) 301 302 /* On FE are possible all encodings */ 303 #define PG_VALID_FE_ENCODING(_enc) PG_VALID_ENCODING(_enc) 304 305 /* 306 * Table for mapping an encoding number to official encoding name and 307 * possibly other subsidiary data. Be careful to check encoding number 308 * before accessing a table entry! 309 * 310 * if (PG_VALID_ENCODING(encoding)) 311 * pg_enc2name_tbl[ encoding ]; 312 */ 313 typedef struct pg_enc2name 314 { 315 const char *name; 316 pg_enc encoding; 317 #ifdef WIN32 318 unsigned codepage; /* codepage for WIN32 */ 319 #endif 320 } pg_enc2name; 321 322 extern const pg_enc2name pg_enc2name_tbl[]; 323 324 /* 325 * Encoding names for gettext 326 */ 327 typedef struct pg_enc2gettext 328 { 329 pg_enc encoding; 330 const char *name; 331 } pg_enc2gettext; 332 333 extern const pg_enc2gettext pg_enc2gettext_tbl[]; 334 335 /* 336 * pg_wchar stuff 337 */ 338 typedef int (*mb2wchar_with_len_converter) (const unsigned char *from, 339 pg_wchar *to, 340 int len); 341 342 typedef int (*wchar2mb_with_len_converter) (const pg_wchar *from, 343 unsigned char *to, 344 int len); 345 346 typedef int (*mblen_converter) (const unsigned char *mbstr); 347 348 typedef int (*mbdisplaylen_converter) (const unsigned char *mbstr); 349 350 typedef bool (*mbcharacter_incrementer) (unsigned char *mbstr, int len); 351 352 typedef int (*mbverifier) (const unsigned char *mbstr, int len); 353 354 typedef struct 355 { 356 mb2wchar_with_len_converter mb2wchar_with_len; /* convert a multibyte 357 * string to a wchar */ 358 wchar2mb_with_len_converter wchar2mb_with_len; /* convert a wchar 359 * string to a multibyte */ 360 mblen_converter mblen; /* get byte length of a char */ 361 mbdisplaylen_converter dsplen; /* get display width of a char */ 362 mbverifier mbverify; /* verify multibyte sequence */ 363 int maxmblen; /* max bytes for a char in this encoding */ 364 } pg_wchar_tbl; 365 366 extern const pg_wchar_tbl pg_wchar_table[]; 367 368 /* 369 * Data structures for conversions between UTF-8 and other encodings 370 * (UtfToLocal() and LocalToUtf()). In these data structures, characters of 371 * either encoding are represented by uint32 words; hence we can only support 372 * characters up to 4 bytes long. For example, the byte sequence 0xC2 0x89 373 * would be represented by 0x0000C289, and 0xE8 0xA2 0xB4 by 0x00E8A2B4. 374 * 375 * Maps are arrays of these structs, which must be in order by the lookup key 376 * (so that bsearch() can be used). 377 * 378 * UTF-8 to local code conversion map 379 */ 380 typedef struct 381 { 382 uint32 utf; /* UTF-8 */ 383 uint32 code; /* local code */ 384 } pg_utf_to_local; 385 386 /* 387 * local code to UTF-8 conversion map 388 */ 389 typedef struct 390 { 391 uint32 code; /* local code */ 392 uint32 utf; /* UTF-8 */ 393 } pg_local_to_utf; 394 395 /* 396 * UTF-8 to local code conversion map (for combined characters) 397 */ 398 typedef struct 399 { 400 uint32 utf1; /* UTF-8 code 1 */ 401 uint32 utf2; /* UTF-8 code 2 */ 402 uint32 code; /* local code */ 403 } pg_utf_to_local_combined; 404 405 /* 406 * local code to UTF-8 conversion map (for combined characters) 407 */ 408 typedef struct 409 { 410 uint32 code; /* local code */ 411 uint32 utf1; /* UTF-8 code 1 */ 412 uint32 utf2; /* UTF-8 code 2 */ 413 } pg_local_to_utf_combined; 414 415 /* 416 * callback function for algorithmic encoding conversions (in either direction) 417 * 418 * if function returns zero, it does not know how to convert the code 419 */ 420 typedef uint32 (*utf_local_conversion_func) (uint32 code); 421 422 /* 423 * Support macro for encoding conversion functions to validate their 424 * arguments. (This could be made more compact if we included fmgr.h 425 * here, but we don't want to do that because this header file is also 426 * used by frontends.) 427 */ 428 #define CHECK_ENCODING_CONVERSION_ARGS(srcencoding,destencoding) \ 429 check_encoding_conversion_args(PG_GETARG_INT32(0), \ 430 PG_GETARG_INT32(1), \ 431 PG_GETARG_INT32(4), \ 432 (srcencoding), \ 433 (destencoding)) 434 435 436 /* 437 * These functions are considered part of libpq's exported API and 438 * are also declared in libpq-fe.h. 439 */ 440 extern int pg_char_to_encoding(const char *name); 441 extern const char *pg_encoding_to_char(int encoding); 442 extern int pg_valid_server_encoding_id(int encoding); 443 444 /* 445 * Remaining functions are not considered part of libpq's API, though many 446 * of them do exist inside libpq. 447 */ 448 extern int pg_mb2wchar(const char *from, pg_wchar *to); 449 extern int pg_mb2wchar_with_len(const char *from, pg_wchar *to, int len); 450 extern int pg_encoding_mb2wchar_with_len(int encoding, 451 const char *from, pg_wchar *to, int len); 452 extern int pg_wchar2mb(const pg_wchar *from, char *to); 453 extern int pg_wchar2mb_with_len(const pg_wchar *from, char *to, int len); 454 extern int pg_encoding_wchar2mb_with_len(int encoding, 455 const pg_wchar *from, char *to, int len); 456 extern int pg_char_and_wchar_strcmp(const char *s1, const pg_wchar *s2); 457 extern int pg_wchar_strncmp(const pg_wchar *s1, const pg_wchar *s2, size_t n); 458 extern int pg_char_and_wchar_strncmp(const char *s1, const pg_wchar *s2, size_t n); 459 extern size_t pg_wchar_strlen(const pg_wchar *wstr); 460 extern int pg_mblen(const char *mbstr); 461 extern int pg_dsplen(const char *mbstr); 462 extern int pg_encoding_mblen(int encoding, const char *mbstr); 463 extern int pg_encoding_dsplen(int encoding, const char *mbstr); 464 extern int pg_encoding_verifymb(int encoding, const char *mbstr, int len); 465 extern int pg_mule_mblen(const unsigned char *mbstr); 466 extern int pg_mic_mblen(const unsigned char *mbstr); 467 extern int pg_mbstrlen(const char *mbstr); 468 extern int pg_mbstrlen_with_len(const char *mbstr, int len); 469 extern int pg_mbcliplen(const char *mbstr, int len, int limit); 470 extern int pg_encoding_mbcliplen(int encoding, const char *mbstr, 471 int len, int limit); 472 extern int pg_mbcharcliplen(const char *mbstr, int len, int imit); 473 extern int pg_encoding_max_length(int encoding); 474 extern int pg_database_encoding_max_length(void); 475 extern mbcharacter_incrementer pg_database_encoding_character_incrementer(void); 476 477 extern int PrepareClientEncoding(int encoding); 478 extern int SetClientEncoding(int encoding); 479 extern void InitializeClientEncoding(void); 480 extern int pg_get_client_encoding(void); 481 extern const char *pg_get_client_encoding_name(void); 482 483 extern void SetDatabaseEncoding(int encoding); 484 extern int GetDatabaseEncoding(void); 485 extern const char *GetDatabaseEncodingName(void); 486 extern void SetMessageEncoding(int encoding); 487 extern int GetMessageEncoding(void); 488 489 #ifdef ENABLE_NLS 490 extern int pg_bind_textdomain_codeset(const char *domainname); 491 #endif 492 493 extern int pg_valid_client_encoding(const char *name); 494 extern int pg_valid_server_encoding(const char *name); 495 496 extern unsigned char *unicode_to_utf8(pg_wchar c, unsigned char *utf8string); 497 extern pg_wchar utf8_to_unicode(const unsigned char *c); 498 extern int pg_utf_mblen(const unsigned char *); 499 extern unsigned char *pg_do_encoding_conversion(unsigned char *src, int len, 500 int src_encoding, 501 int dest_encoding); 502 503 extern char *pg_client_to_server(const char *s, int len); 504 extern char *pg_server_to_client(const char *s, int len); 505 extern char *pg_any_to_server(const char *s, int len, int encoding); 506 extern char *pg_server_to_any(const char *s, int len, int encoding); 507 508 extern unsigned short BIG5toCNS(unsigned short big5, unsigned char *lc); 509 extern unsigned short CNStoBIG5(unsigned short cns, unsigned char lc); 510 511 extern void UtfToLocal(const unsigned char *utf, int len, 512 unsigned char *iso, 513 const pg_utf_to_local *map, int mapsize, 514 const pg_utf_to_local_combined *cmap, int cmapsize, 515 utf_local_conversion_func conv_func, 516 int encoding); 517 extern void LocalToUtf(const unsigned char *iso, int len, 518 unsigned char *utf, 519 const pg_local_to_utf *map, int mapsize, 520 const pg_local_to_utf_combined *cmap, int cmapsize, 521 utf_local_conversion_func conv_func, 522 int encoding); 523 524 extern bool pg_verifymbstr(const char *mbstr, int len, bool noError); 525 extern bool pg_verify_mbstr(int encoding, const char *mbstr, int len, 526 bool noError); 527 extern int pg_verify_mbstr_len(int encoding, const char *mbstr, int len, 528 bool noError); 529 530 extern void check_encoding_conversion_args(int src_encoding, 531 int dest_encoding, 532 int len, 533 int expected_src_encoding, 534 int expected_dest_encoding); 535 536 extern void report_invalid_encoding(int encoding, const char *mbstr, int len) pg_attribute_noreturn(); 537 extern void report_untranslatable_char(int src_encoding, int dest_encoding, 538 const char *mbstr, int len) pg_attribute_noreturn(); 539 540 extern void local2local(const unsigned char *l, unsigned char *p, int len, 541 int src_encoding, int dest_encoding, const unsigned char *tab); 542 extern void pg_ascii2mic(const unsigned char *l, unsigned char *p, int len); 543 extern void pg_mic2ascii(const unsigned char *mic, unsigned char *p, int len); 544 extern void latin2mic(const unsigned char *l, unsigned char *p, int len, 545 int lc, int encoding); 546 extern void mic2latin(const unsigned char *mic, unsigned char *p, int len, 547 int lc, int encoding); 548 extern void latin2mic_with_table(const unsigned char *l, unsigned char *p, 549 int len, int lc, int encoding, 550 const unsigned char *tab); 551 extern void mic2latin_with_table(const unsigned char *mic, unsigned char *p, 552 int len, int lc, int encoding, 553 const unsigned char *tab); 554 555 extern bool pg_utf8_islegal(const unsigned char *source, int length); 556 557 #ifdef WIN32 558 extern WCHAR *pgwin32_message_to_UTF16(const char *str, int len, int *utf16len); 559 #endif 560 561 #endif /* PG_WCHAR_H */ 562