ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/encoding.C
(Generate patch)

Comparing rxvt-unicode/src/encoding.C (file contents):
Revision 1.1 by pcg, Mon Nov 24 17:28:08 2003 UTC vs.
Revision 1.15 by pcg, Mon Mar 15 01:27:46 2004 UTC

8const struct n2cs { 8const struct n2cs {
9 const char *name; 9 const char *name;
10 codeset cs; 10 codeset cs;
11} n2cs[] = { 11} n2cs[] = {
12 /* first one found is the normalized one */ 12 /* first one found is the normalized one */
13 { "ISO88591", CS_ISO8859_1 }, 13 { "ISO88591", CS_ISO8859_1 },
14 { "ISO8859PRIMARY", CS_ISO8859_1 }, // some stupid fonts use this (hi tigert) 14 { "ISO8859PRIMARY", CS_ISO8859_1 }, // some stupid fonts use this (hi tigert)
15 { "ISO88592", CS_ISO8859_2 }, 15 { "ISO88592", CS_ISO8859_2 },
16 { "ISO88593", CS_ISO8859_3 }, 16 { "ISO88593", CS_ISO8859_3 },
17 { "ISO88594", CS_ISO8859_4 }, 17 { "ISO88594", CS_ISO8859_4 },
18 { "ISO88595", CS_ISO8859_5 }, 18 { "ISO88595", CS_ISO8859_5 },
19 { "ISO88596", CS_ISO8859_6 }, 19 { "ISO88596", CS_ISO8859_6 },
20 { "ISO88597", CS_ISO8859_7 }, 20 { "ISO88597", CS_ISO8859_7 },
21 { "ISO88598", CS_ISO8859_8 }, 21 { "ISO88598", CS_ISO8859_8 },
22 { "ISO88599", CS_ISO8859_9 }, 22 { "ISO88599", CS_ISO8859_9 },
23 { "ISO885910", CS_ISO8859_10 }, 23 { "ISO885910", CS_ISO8859_10 },
24 { "ISO885911", CS_ISO8859_11 }, 24 { "ISO885911", CS_ISO8859_11 },
25 { "ISO885913", CS_ISO8859_13 }, 25 { "ISO885913", CS_ISO8859_13 },
26 { "ISO885914", CS_ISO8859_14 }, 26 { "ISO885914", CS_ISO8859_14 },
27 { "ISO885915", CS_ISO8859_15 }, 27 { "ISO885915", CS_ISO8859_15 },
28 { "FCD885915", CS_ISO8859_15 }, 28 { "FCD885915", CS_ISO8859_15 },
29 { "ISO885916", CS_ISO8859_16 }, 29 { "ISO885916", CS_ISO8859_16 },
30
31 { "TIS620*", CS_ISO8859_11 }, // close enough
30 32
31 { "ISO106461", CS_UNICODE }, 33 { "ISO10646*", CS_UNICODE },
32 { "UNICODE", CS_UNICODE }, 34 { "UNICODE", CS_UNICODE },
33 { "UTF8", CS_UNICODE }, 35 { "UTF8", CS_UNICODE },
34 36
35 { "ASCII", CS_US_ASCII }, 37 { "ASCII", CS_US_ASCII },
36 { "USASCII", CS_US_ASCII }, 38 { "USASCII", CS_US_ASCII },
37 { "ANSIX341968", CS_US_ASCII }, 39 { "ANSIX341968", CS_US_ASCII },
38 40
39 { "KOI8R", CS_KOI8_R }, 41 { "KOI8R", CS_KOI8_R },
40 { "GOST19768741", CS_KOI8_R }, 42 { "GOST1976874*", CS_KOI8_R },
43 { "KOI8RU", CS_KOI8_U },
41 { "KOI8U", CS_KOI8_U }, 44 { "KOI8U", CS_KOI8_U },
42 45
43 { "KSC560119870", CS_KSC5601_1987_0 },
44 { "KSX100119970", CS_KSC5601_1987_0 },
45 { "KSX100119980", CS_KSC5601_1987_0 }, // adds johab
46
47 { "GB231219800", CS_GB2312_1980_0 },
48
49 { "VISCII", CS_VISCII }, 46 { "VISCII*", CS_VISCII },
50 { "VISCII111", CS_VISCII }, 47
51 { "TIS62025291", CS_VISCII }, /* close enough */
52
53 { "JISX020119760", CS_JIS0201_1976_0 }, 48 { "JISX0201*", CS_JIS0201_1976_0 },
54 { "JISX020819830", CS_JIS0208_1983_0 }, 49 { "JISX0208*", CS_JIS0208_1990_0 }, // also wrongly matches -1987-0? (check Encode::JP)
55 { "JISX020819900", CS_JIS0208_1983_0 }, /* ehrm. */
56 { "JISX021219900", CS_JIS0212_1990_0 }, 50 { "JISX0212*", CS_JIS0212_1990_0 },
51 { "JISX021320001", CS_JIS0213_1 },
52 { "JISX021320002", CS_JIS0213_2 },
53 { "JISX0221*", CS_UNICODE }, // _very_ close
54
55 { "KSC5601*", CS_KSC5601_1987_0 },
56 { "KSX1001*", CS_KSC5601_1987_0 },
57 { "KSC5700*", CS_UNICODE }, // unicode plus extensions
58
59 { "BIG5P*", CS_BIG5_PLUS },
60 { "BIG5ETEN*", CS_BIG5_EXT },
61 { "BIG5*", CS_BIG5 },
62 { "GB2312*", CS_GB2312_1980_0 },
63 { "GB6345*", CS_GB2312_1980_0 }, // slightly different to gb2312??
64 { "GB8565*", CS_GB2312_1980_0 }, // a superset of gb2312??
65 { "GB13000*", CS_UNICODE },
66 { "CNS1164319921", CS_CNS11643_1992_1 },
67 { "CNS1164319922", CS_CNS11643_1992_2 },
68 { "CNS1164319923", CS_CNS11643_1992_3 },
69 { "CNS1164319924", CS_CNS11643_1992_4 },
70 { "CNS1164319925", CS_CNS11643_1992_5 },
71 { "CNS1164319926", CS_CNS11643_1992_6 },
72 { "CNS1164319927", CS_CNS11643_1992_7 },
73 { "CNS116431992F", CS_CNS11643_1992_F },
57 74
58 { 0, CS_UNKNOWN } 75 { 0, CS_UNKNOWN }
59}; 76};
60 77
61static const char * 78static const char *
85 name = normalize_name (name); 102 name = normalize_name (name);
86 103
87 const struct n2cs *i = n2cs; 104 const struct n2cs *i = n2cs;
88 105
89 do { 106 do {
107 int len = strlen (i->name);
108
109 if ((i->name[len - 1] == '*'
110 && !strncmp (name, i->name, len - 1))
90 if (!strcmp (name, i->name)) 111 || !strcmp (name, i->name))
91 return i->cs; 112 return i->cs;
113
92 } while ((++i)->name); 114 } while ((++i)->name);
93 115
94 return CS_UNKNOWN; 116 return CS_UNKNOWN;
95} 117}
96 118
97struct rxvt_codeset_conv_unknown : rxvt_codeset_conv { 119struct rxvt_codeset_conv_unknown : rxvt_codeset_conv {
98 uint32_t to_unicode (uint32_t enc) const { return NOCHAR; } 120 unicode_t to_unicode (uint32_t enc) const { return NOCHAR; }
99 uint32_t from_unicode (uint32_t unicode) const { return NOCHAR; } 121 uint32_t from_unicode (unicode_t unicode) const { return NOCHAR; }
100} rxvt_codeset_conv_unknown; 122} rxvt_codeset_conv_unknown;
101 123
102struct rxvt_codeset_conv_us_ascii : rxvt_codeset_conv { 124struct rxvt_codeset_conv_us_ascii : rxvt_codeset_conv {
103 uint32_t from_unicode (uint32_t unicode) const { return unicode <= 127 ? unicode : NOCHAR; } 125 uint32_t from_unicode (unicode_t unicode) const { return unicode <= 127 ? unicode : NOCHAR; }
104} rxvt_codeset_conv_us_ascii; 126} rxvt_codeset_conv_us_ascii;
105 127
106struct rxvt_codeset_conv_unicode : rxvt_codeset_conv { 128struct rxvt_codeset_conv_unicode : rxvt_codeset_conv {
107 /* transparent */ 129 /* transparent */
108} rxvt_codeset_conv_unicode; 130} rxvt_codeset_conv_unicode;
109 131
110struct rxvt_codeset_conv_unicode_16 : rxvt_codeset_conv { 132struct rxvt_codeset_conv_unicode_16 : rxvt_codeset_conv {
111 uint32_t to_unicode (uint32_t enc) const { return enc; } 133 unicode_t to_unicode (uint32_t enc) const { return enc; }
112 uint32_t from_unicode (uint32_t unicode) const { return unicode <= 65535 ? unicode : NOCHAR; } 134 uint32_t from_unicode (unicode_t unicode) const { return unicode <= 65535 ? unicode : NOCHAR; }
113} rxvt_codeset_conv_unicode_16; 135} rxvt_codeset_conv_unicode_16;
114
115/* block character set, must conform to the dec special pseudofont in defaultfont.C */
116struct rxvt_codeset_conv_special : rxvt_codeset_conv {
117 uint32_t to_unicode (uint32_t enc) const {
118 return enc;
119 }
120
121 uint32_t from_unicode (uint32_t unicode) const {
122 return unicode;
123 }
124} rxvt_codeset_conv_special;
125 136
126#define ENCODING_DEFAULT 137#define ENCODING_DEFAULT
127 138
128#include "table/iso8859_1.h" 139#include "table/iso8859_1.h"
129#include "table/iso8859_15.h" 140#include "table/iso8859_15.h"
152#include "table/ksc5601_1987_0.h" 163#include "table/ksc5601_1987_0.h"
153 164
154//#define ENCODING_CN 165//#define ENCODING_CN
155 166
156#include "table/gb2312_1980_0.h" 167#include "table/gb2312_1980_0.h"
168#include "table/big5.h"
157 169
158//#define ENCODING_CN_EXT 170//#define ENCODING_CN_EXT
159 171
160#include "table/cns11643_1992_1.h" 172#include "table/cns11643_1992_1.h"
161#include "table/cns11643_1992_2.h" 173#include "table/cns11643_1992_2.h"
173#include "table/viscii.h" 185#include "table/viscii.h"
174 186
175//#define ENCODING_JP 187//#define ENCODING_JP
176 188
177#include "table/jis0201_1976_0.h" 189#include "table/jis0201_1976_0.h"
178#include "table/jis0208_1983_0.h" 190#include "table/jis0208_1990_0.h"
179#include "table/jis0212_1990_0.h" 191#include "table/jis0212_1990_0.h"
180 192
181//#define ENCODING_JP_EXT 193//#define ENCODING_JP_EXT
182 194
183#include "table/jis0213_1.h" 195#include "table/jis0213_1.h"
184#include "table/jis0213_2.h" 196#include "table/jis0213_2.h"
185 197
198// order must match table in encoding.h(!)
186const rxvt_codeset_conv *rxvt_codeset[NUM_CODESETS] = { 199const rxvt_codeset_conv *rxvt_codeset[NUM_CODESETS] = {
187 &rxvt_codeset_conv_unknown, 200 &rxvt_codeset_conv_unknown,
188 &rxvt_codeset_conv_special,
189 201
190 &rxvt_codeset_conv_us_ascii, 202 &rxvt_codeset_conv_us_ascii,
191 203
192 &rxvt_codeset_conv_iso8859_1, 204 &rxvt_codeset_conv_iso8859_1,
193 &rxvt_codeset_conv_iso8859_2, 205 &rxvt_codeset_conv_iso8859_2,
207 219
208 &rxvt_codeset_conv_koi8_r, 220 &rxvt_codeset_conv_koi8_r,
209 &rxvt_codeset_conv_koi8_u, 221 &rxvt_codeset_conv_koi8_u,
210 222
211 &rxvt_codeset_conv_jis0201_1976_0, 223 &rxvt_codeset_conv_jis0201_1976_0,
212 &rxvt_codeset_conv_jis0208_1983_0, 224 &rxvt_codeset_conv_jis0208_1990_0,
213 &rxvt_codeset_conv_jis0212_1990_0, 225 &rxvt_codeset_conv_jis0212_1990_0,
214 226
215 &rxvt_codeset_conv_jis0213_1, 227 &rxvt_codeset_conv_jis0213_1,
216 &rxvt_codeset_conv_jis0213_2, 228 &rxvt_codeset_conv_jis0213_2,
217 229
225 &rxvt_codeset_conv_cns11643_1992_4, 237 &rxvt_codeset_conv_cns11643_1992_4,
226 &rxvt_codeset_conv_cns11643_1992_5, 238 &rxvt_codeset_conv_cns11643_1992_5,
227 &rxvt_codeset_conv_cns11643_1992_6, 239 &rxvt_codeset_conv_cns11643_1992_6,
228 &rxvt_codeset_conv_cns11643_1992_7, 240 &rxvt_codeset_conv_cns11643_1992_7,
229 &rxvt_codeset_conv_cns11643_1992_f, 241 &rxvt_codeset_conv_cns11643_1992_f,
242 &rxvt_codeset_conv_big5,
230 &rxvt_codeset_conv_big5_ext, 243 &rxvt_codeset_conv_big5_ext,
231 &rxvt_codeset_conv_big5_plus, 244 &rxvt_codeset_conv_big5_plus,
232 245
233 &rxvt_codeset_conv_viscii, 246 &rxvt_codeset_conv_viscii,
234 247
235 &rxvt_codeset_conv_unicode_16, 248 &rxvt_codeset_conv_unicode_16,
236 &rxvt_codeset_conv_unicode 249 &rxvt_codeset_conv_unicode
237}; 250};
238 251
252#if ENABLE_COMBINING
253# define ENCODING_COMPOSE
254#endif
255
256#include "table/compose.h"
257
258unicode_t
259rxvt_compose (unicode_t c1, unicode_t c2)
260{
261 int l = 0;
262 int r = sizeof (rxvt_compose_table) / sizeof (rxvt_compose_entry) - 1;
263 int m;
264
265 while (r > l)
266 {
267 m = (l + r) / 2;
268 rxvt_compose_entry &c = rxvt_compose_table[m];
269
270 if (c.c1 < c1 || (c.c1 == c1 && c.c2 < c2))
271 l = m + 1;
272 else if (c.c1 > c1 || (c.c1 == c1 && c.c2 > c2))
273 r = m - 1;
274 else
275 return c.r;
276 }
277
278 return NOCHAR;
279}
280
281#include "table/category.h"
282
283bool unicode::is_space (unicode_t c)
284{
285 return IS_SPACE (c);
286}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines