32 #define MAX_MULTIBYTE_CHAR_LEN 4
43 #define ISSJISHEAD(c) (((c) >= 0x81 && (c) <= 0x9f) || ((c) >= 0xe0 && (c) <= 0xfc))
44 #define ISSJISTAIL(c) (((c) >= 0x40 && (c) <= 0x7e) || ((c) >= 0x80 && (c) <= 0xfc))
104 #define LC_ISO8859_1 0x81
105 #define LC_ISO8859_2 0x82
106 #define LC_ISO8859_3 0x83
107 #define LC_ISO8859_4 0x84
108 #define LC_TIS620 0x85
109 #define LC_ISO8859_7 0x86
110 #define LC_ISO8859_6 0x87
111 #define LC_ISO8859_8 0x88
112 #define LC_JISX0201K 0x89
113 #define LC_JISX0201R 0x8a
118 #define LC_KOI8_R 0x8b
119 #define LC_ISO8859_5 0x8c
120 #define LC_ISO8859_9 0x8d
121 #define LC_ISO8859_15 0x8e
125 #define IS_LC1(c) ((unsigned char)(c) >= 0x81 && (unsigned char)(c) <= 0x8d)
131 #define LC_JISX0208_1978 0x90
132 #define LC_GB2312_80 0x91
133 #define LC_JISX0208 0x92
134 #define LC_KS5601 0x93
135 #define LC_JISX0212 0x94
136 #define LC_CNS11643_1 0x95
137 #define LC_CNS11643_2 0x96
138 #define LC_JISX0213_1 0x97
140 #define LC_BIG5_1 0x98
142 #define LC_BIG5_2 0x99
146 #define IS_LC2(c) ((unsigned char)(c) >= 0x90 && (unsigned char)(c) <= 0x99)
152 #define LCPRV1_A 0x9a
153 #define LCPRV1_B 0x9b
154 #define IS_LCPRV1(c) ((unsigned char)(c) == LCPRV1_A || (unsigned char)(c) == LCPRV1_B)
155 #define IS_LCPRV1_A_RANGE(c) \
156 ((unsigned char)(c) >= 0xa0 && (unsigned char)(c) <= 0xdf)
157 #define IS_LCPRV1_B_RANGE(c) \
158 ((unsigned char)(c) >= 0xe0 && (unsigned char)(c) <= 0xef)
164 #define LCPRV2_A 0x9c
165 #define LCPRV2_B 0x9d
166 #define IS_LCPRV2(c) ((unsigned char)(c) == LCPRV2_A || (unsigned char)(c) == LCPRV2_B)
167 #define IS_LCPRV2_A_RANGE(c) \
168 ((unsigned char)(c) >= 0xf0 && (unsigned char)(c) <= 0xf4)
169 #define IS_LCPRV2_B_RANGE(c) \
170 ((unsigned char)(c) >= 0xf5 && (unsigned char)(c) <= 0xfe)
175 #define LC_SISHENG 0xa0
179 #define LC_VISCII_LOWER 0xa2
181 #define LC_VISCII_UPPER 0xa3
183 #define LC_ARABIC_DIGIT 0xa4
184 #define LC_ARABIC_1_COLUMN 0xa5
185 #define LC_ASCII_RIGHT_TO_LEFT 0xa6
190 #define LC_ARABIC_2_COLUMN 0xa8
195 #define LC_INDIAN_1_COLUMN 0xf0
197 #define LC_TIBETAN_1_COLUMN 0xf1
199 #define LC_UNICODE_SUBSET_2 0xf2
201 #define LC_UNICODE_SUBSET_3 0xf3
203 #define LC_UNICODE_SUBSET 0xf4
205 #define LC_ETHIOPIC 0xf5
206 #define LC_CNS11643_3 0xf6
207 #define LC_CNS11643_4 0xf7
208 #define LC_CNS11643_5 0xf8
209 #define LC_CNS11643_6 0xf9
210 #define LC_CNS11643_7 0xfa
211 #define LC_INDIAN_2_COLUMN 0xfb
213 #define LC_TIBETAN 0xfc
291 #define PG_ENCODING_BE_LAST PG_KOI8U
297 #define PG_VALID_BE_ENCODING(_enc) \
298 ((_enc) >= 0 && (_enc) <= PG_ENCODING_BE_LAST)
300 #define PG_ENCODING_IS_CLIENT_ONLY(_enc) \
301 ((_enc) > PG_ENCODING_BE_LAST && (_enc) < _PG_LAST_ENCODING_)
303 #define PG_VALID_ENCODING(_enc) \
304 ((_enc) >= 0 && (_enc) < _PG_LAST_ENCODING_)
307 #define PG_VALID_FE_ENCODING(_enc) PG_VALID_ENCODING(_enc)
318 #define MAX_CONVERSION_GROWTH 4
336 #define MAX_CONVERSION_INPUT_LENGTH 16
345 #define MAX_UNICODE_EQUIVALENT_STRING 16
529 #define CHECK_ENCODING_CONVERSION_ARGS(srcencoding,destencoding) \
530 check_encoding_conversion_args(PG_GETARG_INT32(0), \
531 PG_GETARG_INT32(1), \
532 PG_GETARG_INT32(4), \
543 return (
c > 0 &&
c <= 0x10FFFF);
549 return (
c >= 0xD800 &&
c <= 0xDBFF);
555 return (
c >= 0xDC00 &&
c <= 0xDFFF);
561 return ((first & 0x3FF) << 10) + 0x10000 + (second & 0x3FF);
610 extern int pg_mblen(
const char *mbstr);
634 extern int pg_bind_textdomain_codeset(
const char *domainname);
643 unsigned char *src,
int srclen,
644 unsigned char *
dest,
int destlen,
655 extern unsigned short BIG5toCNS(
unsigned short big5,
unsigned char *lc);
656 extern unsigned short CNStoBIG5(
unsigned short cns,
unsigned char lc);
680 int expected_src_encoding,
681 int expected_dest_encoding);
687 extern int local2local(
const unsigned char *l,
unsigned char *p,
int len,
688 int src_encoding,
int dest_encoding,
689 const unsigned char *tab,
bool noError);
690 extern int latin2mic(
const unsigned char *l,
unsigned char *p,
int len,
691 int lc,
int encoding,
bool noError);
692 extern int mic2latin(
const unsigned char *mic,
unsigned char *p,
int len,
693 int lc,
int encoding,
bool noError);
696 const unsigned char *tab,
bool noError);
699 const unsigned char *tab,
bool noError);
702 extern WCHAR *pgwin32_message_to_UTF16(
const char *
str,
int len,
int *utf16len);
715 const unsigned char *
const s_end = s +
len;
#define pg_attribute_noreturn()
Assert(fmt[strlen(fmt) - 1] !='\n')
static rewind_source * source
const char * pg_get_client_encoding_name(void)
int pg_encoding_mblen_bounded(int encoding, const char *mbstr)
unsigned char * pg_do_encoding_conversion(unsigned char *src, int len, int src_encoding, int dest_encoding)
int mic2latin_with_table(const unsigned char *mic, unsigned char *p, int len, int lc, int encoding, const unsigned char *tab, bool noError)
bool pg_utf8_islegal(const unsigned char *source, int length)
bool pg_unicode_to_server_noerror(pg_wchar c, unsigned char *s)
char * pg_any_to_server(const char *s, int len, int encoding)
int GetDatabaseEncoding(void)
int pg_encoding_wchar2mb_with_len(int encoding, const pg_wchar *from, char *to, int len)
int UtfToLocal(const unsigned char *utf, int len, unsigned char *iso, const pg_mb_radix_tree *map, const pg_utf_to_local_combined *cmap, int cmapsize, utf_local_conversion_func conv_func, int encoding, bool noError)
const char * get_encoding_name_for_icu(int encoding)
uint32(* utf_local_conversion_func)(uint32 code)
unsigned char * unicode_to_utf8(pg_wchar c, unsigned char *utf8string)
int(* wchar2mb_with_len_converter)(const pg_wchar *from, unsigned char *to, int len)
int pg_verify_mbstr_len(int encoding, const char *mbstr, int len, bool noError)
void InitializeClientEncoding(void)
int pg_dsplen(const char *mbstr)
int pg_mbstrlen_with_len(const char *mbstr, int limit)
mbcharacter_incrementer pg_database_encoding_character_incrementer(void)
char * pg_client_to_server(const char *s, int len)
int pg_wchar2mb_with_len(const pg_wchar *from, char *to, int len)
int pg_utf_mblen(const unsigned char *s)
int latin2mic_with_table(const unsigned char *l, unsigned char *p, int len, int lc, int encoding, const unsigned char *tab, bool noError)
int pg_mb2wchar(const char *from, pg_wchar *to)
int pg_char_to_encoding(const char *name)
bool(* mbcharacter_incrementer)(unsigned char *mbstr, int len)
static bool is_valid_ascii(const unsigned char *s, int len)
int(* mbchar_verifier)(const unsigned char *mbstr, int len)
int pg_mbcharcliplen(const char *mbstr, int len, int limit)
int mic2latin(const unsigned char *mic, unsigned char *p, int len, int lc, int encoding, bool noError)
struct pg_enc2name pg_enc2name
int pg_valid_server_encoding_id(int encoding)
unsigned short CNStoBIG5(unsigned short cns, unsigned char lc)
size_t pg_wchar_strlen(const pg_wchar *str)
int pg_wchar2mb(const pg_wchar *from, char *to)
void report_untranslatable_char(int src_encoding, int dest_encoding, const char *mbstr, int len) pg_attribute_noreturn()
int pg_mule_mblen(const unsigned char *s)
PGDLLIMPORT const pg_enc2name pg_enc2name_tbl[]
int pg_mbstrlen(const char *mbstr)
bool pg_verify_mbstr(int encoding, const char *mbstr, int len, bool noError)
PGDLLIMPORT const pg_enc2gettext pg_enc2gettext_tbl[]
bool pg_verifymbstr(const char *mbstr, int len, bool noError)
int LocalToUtf(const unsigned char *iso, int len, unsigned char *utf, const pg_mb_radix_tree *map, const pg_local_to_utf_combined *cmap, int cmapsize, utf_local_conversion_func conv_func, int encoding, bool noError)
int pg_mbcliplen(const char *mbstr, int len, int limit)
int GetMessageEncoding(void)
pg_wchar utf8_to_unicode(const unsigned char *c)
int pg_do_encoding_conversion_buf(Oid proc, int src_encoding, int dest_encoding, unsigned char *src, int srclen, unsigned char *dest, int destlen, bool noError)
int SetClientEncoding(int encoding)
void SetMessageEncoding(int encoding)
void pg_unicode_to_server(pg_wchar c, unsigned char *s)
static bool is_valid_unicode_codepoint(pg_wchar c)
int pg_valid_server_encoding(const char *name)
struct pg_enc2gettext pg_enc2gettext
void check_encoding_conversion_args(int src_encoding, int dest_encoding, int len, int expected_src_encoding, int expected_dest_encoding)
int pg_database_encoding_max_length(void)
int PrepareClientEncoding(int encoding)
int pg_valid_client_encoding(const char *name)
int pg_encoding_dsplen(int encoding, const char *mbstr)
const char * GetDatabaseEncodingName(void)
void report_invalid_encoding(int encoding, const char *mbstr, int len) pg_attribute_noreturn()
int pg_char_and_wchar_strcmp(const char *s1, const pg_wchar *s2)
char * pg_server_to_client(const char *s, int len)
unsigned short BIG5toCNS(unsigned short big5, unsigned char *lc)
int pg_encoding_verifymbstr(int encoding, const char *mbstr, int len)
int pg_get_client_encoding(void)
bool is_encoding_supported_by_icu(int encoding)
int(* mb2wchar_with_len_converter)(const unsigned char *from, pg_wchar *to, int len)
int(* mbstr_verifier)(const unsigned char *mbstr, int len)
int local2local(const unsigned char *l, unsigned char *p, int len, int src_encoding, int dest_encoding, const unsigned char *tab, bool noError)
const char * pg_encoding_to_char(int encoding)
int pg_encoding_max_length(int encoding)
int pg_encoding_mblen(int encoding, const char *mbstr)
PGDLLIMPORT const pg_wchar_tbl pg_wchar_table[]
static pg_wchar surrogate_pair_to_codepoint(pg_wchar first, pg_wchar second)
int pg_wchar_strncmp(const pg_wchar *s1, const pg_wchar *s2, size_t n)
static bool is_utf16_surrogate_first(pg_wchar c)
void SetDatabaseEncoding(int encoding)
int latin2mic(const unsigned char *l, unsigned char *p, int len, int lc, int encoding, bool noError)
int pg_encoding_mbcliplen(int encoding, const char *mbstr, int len, int limit)
int pg_char_and_wchar_strncmp(const char *s1, const pg_wchar *s2, size_t n)
int pg_encoding_verifymbchar(int encoding, const char *mbstr, int len)
int pg_encoding_mb2wchar_with_len(int encoding, const char *from, pg_wchar *to, int len)
char * pg_server_to_any(const char *s, int len, int encoding)
int(* mbdisplaylen_converter)(const unsigned char *mbstr)
int pg_mb2wchar_with_len(const char *from, pg_wchar *to, int len)
static bool is_utf16_surrogate_second(pg_wchar c)
int pg_mblen(const char *mbstr)
int(* mblen_converter)(const unsigned char *mbstr)
static Vector8 vector8_broadcast(const uint8 c)
static void vector8_load(Vector8 *v, const uint8 *s)
static Vector8 vector8_or(const Vector8 v1, const Vector8 v2)
static bool vector8_is_highbit_set(const Vector8 v)