1 | #ifndef ENCODING_H |
1 | #ifndef ENCODING_H |
2 | #define ENCODING_H |
2 | #define ENCODING_H |
3 | |
3 | |
4 | #include <stdint.h> |
4 | #include <inttypes.h> |
5 | |
5 | |
|
|
6 | typedef uint32_t unicode_t; |
|
|
7 | |
|
|
8 | // order must match the table in encoding.C(!) |
6 | enum codeset { |
9 | enum codeset { |
7 | CS_UNKNOWN = 0, |
10 | CS_UNKNOWN = 0, |
8 | CS_SPECIAL, |
|
|
9 | CS_US_ASCII, |
11 | CS_US_ASCII, |
10 | |
12 | |
11 | CS_ISO8859_1, |
13 | CS_ISO8859_1, |
12 | CS_ISO8859_2, |
14 | CS_ISO8859_2, |
13 | CS_ISO8859_3, |
15 | CS_ISO8859_3, |
… | |
… | |
25 | CS_ISO8859_16, |
27 | CS_ISO8859_16, |
26 | |
28 | |
27 | CS_KOI8_R, |
29 | CS_KOI8_R, |
28 | CS_KOI8_U, |
30 | CS_KOI8_U, |
29 | CS_JIS0201_1976_0, |
31 | CS_JIS0201_1976_0, |
30 | CS_JIS0208_1983_0, |
32 | CS_JIS0208_1990_0, |
31 | CS_JIS0212_1990_0, |
33 | CS_JIS0212_1990_0, |
32 | |
|
|
33 | CS_JIS0213_1, |
34 | CS_JIS0213_1, |
34 | CS_JIS0213_2, |
35 | CS_JIS0213_2, |
35 | |
36 | |
36 | CS_KSC5601_1987_0, |
37 | CS_KSC5601_1987_0, |
37 | |
38 | |
38 | CS_GB2312_1980_0, |
39 | CS_GB2312_1980_0, |
|
|
40 | CS_GBK_0, |
39 | |
41 | |
40 | CS_CNS11643_1992_1, |
42 | CS_CNS11643_1992_1, |
41 | CS_CNS11643_1992_2, |
43 | CS_CNS11643_1992_2, |
42 | CS_CNS11643_1992_3, |
44 | CS_CNS11643_1992_3, |
43 | CS_CNS11643_1992_4, |
45 | CS_CNS11643_1992_4, |
44 | CS_CNS11643_1992_5, |
46 | CS_CNS11643_1992_5, |
45 | CS_CNS11643_1992_6, |
47 | CS_CNS11643_1992_6, |
46 | CS_CNS11643_1992_7, |
48 | CS_CNS11643_1992_7, |
47 | CS_CNS11643_1992_F, |
49 | CS_CNS11643_1992_F, |
48 | |
50 | |
|
|
51 | CS_BIG5, |
49 | CS_BIG5_EXT, |
52 | CS_BIG5_EXT, |
50 | CS_BIG5_PLUS, |
53 | CS_BIG5_PLUS, |
51 | |
54 | |
52 | CS_VISCII, |
55 | CS_VISCII, |
53 | |
56 | |
… | |
… | |
58 | }; |
61 | }; |
59 | |
62 | |
60 | codeset codeset_from_name (const char *name); |
63 | codeset codeset_from_name (const char *name); |
61 | |
64 | |
62 | enum { |
65 | enum { |
63 | ZERO_WIDTH_CHAR = 0x200b, |
66 | ZERO_WIDTH_CHAR = 0x200b, |
|
|
67 | REPLACEMENT_CHAR = 0xfffd, |
64 | NOCHAR = 65535, // must be invalid in ANY codeset(!) |
68 | NOCHAR = 0xfffe, // must be invalid in ANY codeset (!) |
65 | }; |
69 | }; |
66 | |
70 | |
67 | struct rxvt_codeset_conv { |
71 | struct rxvt_codeset_conv { |
68 | virtual uint32_t from_unicode (uint32_t unicode) const { return unicode; } |
72 | uint32_t (*from_unicode) (unicode_t unicode); |
69 | virtual uint32_t to_unicode (uint32_t enc) const { return enc; } |
73 | #if ENCODING_TO_UNICODE |
|
|
74 | unicode_t (*to_unicode) (uint32_t enc); |
|
|
75 | #endif |
70 | }; |
76 | }; |
71 | |
77 | |
72 | extern const rxvt_codeset_conv *rxvt_codeset[NUM_CODESETS]; |
78 | extern const rxvt_codeset_conv rxvt_codeset[NUM_CODESETS]; |
73 | |
79 | |
|
|
80 | extern unicode_t rxvt_compose (unicode_t c1, unicode_t c2); |
|
|
81 | |
74 | #define FROM_UNICODE(cs,code) rxvt_codeset[cs]->from_unicode (code) |
82 | #define FROM_UNICODE(cs,code) rxvt_codeset[cs].from_unicode (code) |
75 | #define TO_UNICODE(cs,code) rxvt_codeset[cs]->to_unicode (code) |
83 | #define TO_UNICODE(cs,code) rxvt_codeset[cs].to_unicode (code) |
|
|
84 | |
|
|
85 | struct unicode { // namespace für arme |
|
|
86 | static bool is_space (unicode_t c); |
|
|
87 | }; |
76 | |
88 | |
77 | #endif |
89 | #endif |
78 | |
90 | |