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.9 by pcg, Wed Mar 10 18:42:58 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_1983_0 }, // also wrongly matches -1990-0 (check Encode::JP)
55 { "JISX020819900", CS_JIS0208_1983_0 }, /* ehrm. */
56 { "JISX021219900", CS_JIS0212_1990_0 }, 50 { "JISX0212*", CS_JIS0212_1990_0 },
51 { "JISX0221*", CS_UNICODE },
52
53 { "KSC5601*", CS_KSC5601_1987_0 },
54 { "KSX1001*", CS_KSC5601_1987_0 },
55 { "KSC5700*", CS_UNICODE }, // unicode plus extensions
56
57 { "BIG5P*", CS_BIG5_PLUS },
58 { "BIG5ETEN*", CS_BIG5_EXT },
59 { "BIG5*", CS_BIG5 },
60 { "GB2312*", CS_GB2312_1980_0 },
61 { "GB6345*", CS_GB2312_1980_0 }, // slightly different to gb2312??
62 { "GB8565*", CS_GB2312_1980_0 }, // a superset of gb2312??
63 { "GB13000*", CS_UNICODE },
64 { "CNS1164319921", CS_CNS11643_1992_1 },
65 { "CNS1164319922", CS_CNS11643_1992_2 },
66 { "CNS1164319923", CS_CNS11643_1992_3 },
67 { "CNS1164319924", CS_CNS11643_1992_4 },
68 { "CNS1164319925", CS_CNS11643_1992_5 },
69 { "CNS1164319926", CS_CNS11643_1992_6 },
70 { "CNS1164319927", CS_CNS11643_1992_7 },
71 { "CNS116431992F", CS_CNS11643_1992_F },
57 72
58 { 0, CS_UNKNOWN } 73 { 0, CS_UNKNOWN }
59}; 74};
60 75
61static const char * 76static const char *
85 name = normalize_name (name); 100 name = normalize_name (name);
86 101
87 const struct n2cs *i = n2cs; 102 const struct n2cs *i = n2cs;
88 103
89 do { 104 do {
105 int len = strlen (i->name);
106
107 if ((i->name[len - 1] == '*'
108 && !strncmp (name, i->name, len - 1))
90 if (!strcmp (name, i->name)) 109 || !strcmp (name, i->name))
91 return i->cs; 110 return i->cs;
111
92 } while ((++i)->name); 112 } while ((++i)->name);
93 113
94 return CS_UNKNOWN; 114 return CS_UNKNOWN;
95} 115}
96 116
109 129
110struct rxvt_codeset_conv_unicode_16 : rxvt_codeset_conv { 130struct rxvt_codeset_conv_unicode_16 : rxvt_codeset_conv {
111 uint32_t to_unicode (uint32_t enc) const { return enc; } 131 uint32_t to_unicode (uint32_t enc) const { return enc; }
112 uint32_t from_unicode (uint32_t unicode) const { return unicode <= 65535 ? unicode : NOCHAR; } 132 uint32_t from_unicode (uint32_t unicode) const { return unicode <= 65535 ? unicode : NOCHAR; }
113} rxvt_codeset_conv_unicode_16; 133} 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 134
126#define ENCODING_DEFAULT 135#define ENCODING_DEFAULT
127 136
128#include "table/iso8859_1.h" 137#include "table/iso8859_1.h"
129#include "table/iso8859_15.h" 138#include "table/iso8859_15.h"
152#include "table/ksc5601_1987_0.h" 161#include "table/ksc5601_1987_0.h"
153 162
154//#define ENCODING_CN 163//#define ENCODING_CN
155 164
156#include "table/gb2312_1980_0.h" 165#include "table/gb2312_1980_0.h"
166#include "table/big5.h"
157 167
158//#define ENCODING_CN_EXT 168//#define ENCODING_CN_EXT
159 169
160#include "table/cns11643_1992_1.h" 170#include "table/cns11643_1992_1.h"
161#include "table/cns11643_1992_2.h" 171#include "table/cns11643_1992_2.h"
181//#define ENCODING_JP_EXT 191//#define ENCODING_JP_EXT
182 192
183#include "table/jis0213_1.h" 193#include "table/jis0213_1.h"
184#include "table/jis0213_2.h" 194#include "table/jis0213_2.h"
185 195
196// order must match table in encoding.h(!)
186const rxvt_codeset_conv *rxvt_codeset[NUM_CODESETS] = { 197const rxvt_codeset_conv *rxvt_codeset[NUM_CODESETS] = {
187 &rxvt_codeset_conv_unknown, 198 &rxvt_codeset_conv_unknown,
188 &rxvt_codeset_conv_special,
189 199
190 &rxvt_codeset_conv_us_ascii, 200 &rxvt_codeset_conv_us_ascii,
191 201
192 &rxvt_codeset_conv_iso8859_1, 202 &rxvt_codeset_conv_iso8859_1,
193 &rxvt_codeset_conv_iso8859_2, 203 &rxvt_codeset_conv_iso8859_2,
225 &rxvt_codeset_conv_cns11643_1992_4, 235 &rxvt_codeset_conv_cns11643_1992_4,
226 &rxvt_codeset_conv_cns11643_1992_5, 236 &rxvt_codeset_conv_cns11643_1992_5,
227 &rxvt_codeset_conv_cns11643_1992_6, 237 &rxvt_codeset_conv_cns11643_1992_6,
228 &rxvt_codeset_conv_cns11643_1992_7, 238 &rxvt_codeset_conv_cns11643_1992_7,
229 &rxvt_codeset_conv_cns11643_1992_f, 239 &rxvt_codeset_conv_cns11643_1992_f,
240 &rxvt_codeset_conv_big5,
230 &rxvt_codeset_conv_big5_ext, 241 &rxvt_codeset_conv_big5_ext,
231 &rxvt_codeset_conv_big5_plus, 242 &rxvt_codeset_conv_big5_plus,
232 243
233 &rxvt_codeset_conv_viscii, 244 &rxvt_codeset_conv_viscii,
234 245
235 &rxvt_codeset_conv_unicode_16, 246 &rxvt_codeset_conv_unicode_16,
236 &rxvt_codeset_conv_unicode 247 &rxvt_codeset_conv_unicode
237}; 248};
238 249
250//#define ENCODING_COMPOSE
251
252#include "table/compose.h"
253
254uint32_t
255rxvt_compose (uint32_t c1, uint32_t c2)
256{
257 int l = 0;
258 int r = sizeof (rxvt_compose_table) / sizeof (rxvt_compose_entry) - 1;
259 int m;
260
261 while (r > l)
262 {
263 m = (l + r) / 2;
264 rxvt_compose_entry &c = rxvt_compose_table[m];
265
266 if (c.c1 < c1 || (c.c1 == c1 && c.c2 < c2))
267 l = m + 1;
268 else if (c.c1 > c1 || (c.c1 == c1 && c.c2 > c2))
269 r = m - 1;
270 else
271 return c.r;
272 }
273
274 return NOCHAR;
275}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines