Intial commit
[profile/ivi/w3m.git] / libwc / gb18030.h
1
2 #ifndef _WC_GB18030_H
3 #define _WC_GB18030_H
4
5 #include "gbk.h"
6
7 #define WC_C_GB18030_UCS2       0x81308130U
8 #define WC_C_GB18030_UCS2_END   0x8431A439U
9 #define WC_C_GB18030_UCS4       0x90308130U
10 #define WC_C_GB18030_UCS4_END   0xE3329A35U
11
12 #define WC_GB18030_NOSTATE      0
13 #define WC_GB18030_MBYTE1       1       /* 0x81 - 0xA0, 0xA1 - 0xFE */
14 #define WC_GB18030_MBYTE2       2       /* 0x30 - 0x39 */
15 #define WC_GB18030_MBYTE3       3       /* 0x81 - 0xA0, 0xA1 - 0xFE */
16
17 #define WC_GB18030_MAP_C0       0x0
18 #define WC_GB18030_MAP_GL       0x1
19 #define WC_GB18030_MAP_C1       0x2
20 #define WC_GB18030_MAP_LB       0x4
21 #define WC_GB18030_MAP_UB       (0x8  | WC_GB18030_MAP_LB)
22 #define WC_GB18030_MAP_L4       0x10
23
24 #define WC_GB18030_N(c) \
25         (((((((c) >> 24) & 0xff) - 0x81) * 0x0A \
26           + (((c) >> 16) & 0xff) - 0x30) * 0x7E \
27           + (((c) >>  8) & 0xff) - 0x81) * 0x0A \
28           + ( (c)        & 0xff) - 0x30)
29 #define WC_N_GB18030(c) \
30          ((((c) / 0x0A / 0x7E / 0xA + 0x81) << 24) \
31         + (((c) / 0x0A / 0x7E % 0xA + 0x30) << 16) \
32         + (((c) / 0x0A % 0x7E       + 0x81) <<  8) \
33         +   (c) % 0xA               + 0x30        )
34
35 extern wc_uchar WC_GB18030_MAP[];
36
37 extern wc_wchar_t wc_gbk_ext_to_cs128w(wc_wchar_t cc);
38 extern wc_wchar_t wc_cs128w_to_gbk_ext(wc_wchar_t cc);
39 #ifdef USE_UNICODE
40 extern wc_uint32  wc_gb18030_to_ucs(wc_wchar_t cc);
41 extern wc_wchar_t wc_ucs_to_gb18030(wc_uint32 ucs);
42 #endif
43 extern Str        wc_conv_from_gb18030(Str is, wc_ces ces);
44 extern void       wc_push_to_gb18030(Str os, wc_wchar_t cc, wc_status *st);
45 extern Str        wc_char_conv_from_gb18030(wc_uchar c, wc_status *st);
46
47 #endif