1 #ifndef	__MULTIBUYTE_H__
2 #define	__MULTIBUYTE_H__
3 /*
4  *
5  * Multibyte library header ( psqlODBC Only )
6  *
7  */
8 #include "psqlodbc.h"
9 #include "qresult.h"
10 
11 /* PostgreSQL client encoding */
12 enum {
13 	SQL_ASCII 	= 0	/* SQL/ASCII */
14 	,EUC_JP			/* EUC for Japanese */
15 	,EUC_CN			/* EUC for Chinese */
16 	,EUC_KR			/* EUC for Korean */
17 	,EUC_TW			/* EUC for Taiwan */
18 	,JOHAB
19 	,UTF8			/* Unicode UTF-8 */
20 	,MULE_INTERNAL		/* Mule internal code */
21 	,LATIN1			/* ISO-8859 Latin 1 */
22 	,LATIN2			/* ISO-8859 Latin 2 */
23 	,LATIN3			/* ISO-8859 Latin 3 */
24 	,LATIN4			/* ISO-8859 Latin 4 */
25 	,LATIN5			/* ISO-8859 Latin 5 */
26 	,LATIN6			/* ISO-8859 Latin 6 */
27 	,LATIN7			/* ISO-8859 Latin 7 */
28 	,LATIN8			/* ISO-8859 Latin 8 */
29 	,LATIN9			/* ISO-8859 Latin 9 */
30 	,LATIN10		/* ISO-8859 Latin 10 */
31 	,WIN1256		/* Arabic Windows */
32 	,WIN1258		/* Vietnamese Windows */
33 	,WIN866			/* Alternativny Variant (MS-DOS CP866) */
34 	,WIN874			/* Thai Windows */
35 	,KOI8R			/* KOI8-R/U */
36 	,WIN1251		/* Cyrillic Windows */
37 	,WIN1252		/* Western Europe Windows */
38 	,ISO_8859_5		/* ISO-8859-5 */
39 	,ISO_8859_6		/* ISO-8859-6 */
40 	,ISO_8859_7		/* ISO-8859-7 */
41 	,ISO_8859_8		/* ISO-8859-8 */
42 	,WIN1250		/* Central Europe Windows */
43 	,WIN1253		/* Greek Windows */
44 	,WIN1254		/* Turkish Windows */
45 	,WIN1255		/* Hebrew Windows */
46 	,WIN1257		/* Baltic(North Europe) Windows */
47 	,EUC_JIS_2004		/* EUC for SHIFT-JIS-2004 Japanese */
48 	,SJIS			/* Shift JIS */
49 	,BIG5			/* Big5 */
50 	,GBK			/* GBK */
51 	,UHC			/* UHC */
52 	,GB18030		/* GB18030 */
53 	,SHIFT_JIS_2004		/* SHIFT-JIS-2004 Japanese, JIS X 0213 */
54 	,OTHER		=	-1
55 };
56 
57 extern int pg_CS_code(const char *stat_string);
58 
59 /* Old Type Compatible */
60 typedef struct
61 {
62 	int	ccsc;
63 	const UCHAR *encstr;
64 	ssize_t	pos;
65 	int	ccst;
66 } encoded_str;
67 #define ENCODE_STATUS(enc)	((enc).ccst)
68 #define ENCODE_PTR(enc)	((enc).encstr + (enc).pos)
69 #define MBCS_NON_ASCII(enc)	(0 != (enc).ccst || (enc).encstr[(enc).pos] >= 0x80)
70 
71 void encoded_str_constr(encoded_str *encstr, int ccsc, const char *str);
72 #define make_encoded_str(encstr, conn, str) encoded_str_constr(encstr, conn->ccsc, str)
73 extern int encoded_nextchar(encoded_str *encstr);
74 extern ssize_t encoded_position_shift(encoded_str *encstr, size_t shift);
75 extern int encoded_byte_check(encoded_str *encstr, size_t abspos);
76 /* #define check_client_encoding(X) pg_CS_name(pg_CS_code(X)) */
77 char *check_client_encoding(const pgNAME sql_string);
78 const char *derive_locale_encoding(const char *dbencoding);
79 int pg_mb_maxlen(int characterset_code);
80 #endif /* __MULTIBUYTE_H__ */
81