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.18 by root, Wed Aug 4 03:29:28 2004 UTC vs.
Revision 1.31 by root, Mon Feb 21 07:41:00 2011 UTC

1/*--------------------------------*-C-*---------------------------------* 1/*----------------------------------------------------------------------*
2 * File: encoding.C 2 * File: encoding.C
3 *----------------------------------------------------------------------* 3 *----------------------------------------------------------------------*
4 * 4 *
5 * All portions of code are copyright by their respective author/s. 5 * All portions of code are copyright by their respective author/s.
6 * Copyright (c) 2003-2004 Marc Lehmann <pcg@goof.com> 6 * Copyright (c) 2003-2006 Marc Lehmann <schmorp@schmorp.de>
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version. 11 * (at your option) any later version.
21 *----------------------------------------------------------------------*/ 21 *----------------------------------------------------------------------*/
22 22
23#include "../config.h" 23#include "../config.h"
24 24
25#include "encoding.h" 25#include "encoding.h"
26#include "rxvtutil.h"
26 27
27#include <cstdlib> 28#include <cstdlib>
28#include <cstring> 29#include <cstring>
29 30
30const struct n2cs { 31static const struct n2cs {
31 const char *name; 32 const char *name;
32 codeset cs; 33 codeset cs;
33} n2cs[] = { 34} n2cs[] = {
34 /* first one found is the normalized one */ 35 /* first one found is the normalized one */
35 { "ISO88591", CS_ISO8859_1 }, 36 { "ISO88591", CS_ISO8859_1 },
47 { "ISO885913", CS_ISO8859_13 }, 48 { "ISO885913", CS_ISO8859_13 },
48 { "ISO885914", CS_ISO8859_14 }, 49 { "ISO885914", CS_ISO8859_14 },
49 { "ISO885915", CS_ISO8859_15 }, 50 { "ISO885915", CS_ISO8859_15 },
50 { "FCD885915", CS_ISO8859_15 }, 51 { "FCD885915", CS_ISO8859_15 },
51 { "ISO885916", CS_ISO8859_16 }, 52 { "ISO885916", CS_ISO8859_16 },
52 53
53 { "TIS620*", CS_ISO8859_11 }, // close enough 54 { "TIS620*", CS_ISO8859_11 }, // close enough
54 55
55 { "ISO10646*", CS_UNICODE }, 56 { "ISO10646*", CS_UNICODE },
56 { "UNICODE", CS_UNICODE }, 57 { "UNICODE", CS_UNICODE },
57 { "UTF8", CS_UNICODE }, 58 { "UTF8", CS_UNICODE },
58 59
59 { "ASCII", CS_US_ASCII }, 60 { "ASCII", CS_US_ASCII },
60 { "USASCII", CS_US_ASCII }, 61 { "USASCII", CS_US_ASCII },
61 { "ANSIX341968", CS_US_ASCII }, 62 { "ANSIX341968", CS_US_ASCII },
62 63 { "ISO6461991IRV", CS_US_ASCII }, // older versions used the currency sign
64
63 { "KOI8R", CS_KOI8_R }, 65 { "KOI8R*", CS_KOI8_R },
64 { "GOST1976874*", CS_KOI8_R }, 66 { "GOST1976874*", CS_KOI8_R },
65 { "KOI8RU", CS_KOI8_U }, 67 { "KOI8RU", CS_KOI8_U },
66 { "KOI8U", CS_KOI8_U }, 68 { "KOI8U", CS_KOI8_U },
67 69
68 { "VISCII*", CS_VISCII }, 70 { "VISCII*", CS_VISCII },
69 71
70 { "JISX0201*", CS_JIS0201_1976_0 }, 72 { "JISX0201*", CS_JIS0201_1976_0 },
71 { "JISC6226*", CS_JIS0208_1990_0 }, // also wrongly matches -1987-0? (check Encode::JP) 73 { "JISC6226*", CS_JIS0208_1990_0 }, // also wrongly matches -1987-0? (check Encode::JP)
72 { "JISX0208*", CS_JIS0208_1990_0 }, // also wrongly matches -1987-0? (check Encode::JP) 74 { "JISX0208*", CS_JIS0208_1990_0 }, // also wrongly matches -1987-0? (check Encode::JP)
73 { "JISX0212*", CS_JIS0212_1990_0 }, 75 { "JISX0212*", CS_JIS0212_1990_0 },
74 { "JISX021320001", CS_JIS0213_1 }, 76 { "JISX021320001", CS_JIS0213_1 },
75 { "JISX021320002", CS_JIS0213_2 }, 77 { "JISX021320002", CS_JIS0213_2 },
76 { "JISX0221*", CS_UNICODE }, // _very_ close 78 { "JISX0221*", CS_UNICODE }, // _very_ close
77 79
78 { "KSC5601*", CS_KSC5601_1987_0 }, 80 { "KSC5601*", CS_KSC5601_1987_0 },
79 { "KSX1001*", CS_KSC5601_1987_0 }, 81 { "KSX1001*", CS_KSC5601_1987_0 },
80 { "KSC5700*", CS_UNICODE }, // unicode plus extensions 82 { "KSC5700*", CS_UNICODE }, // unicode plus extensions
81 83
82 { "BIG5P*", CS_BIG5_PLUS }, 84 { "BIG5P*", CS_BIG5_PLUS },
83 { "BIG5ETEN*", CS_BIG5_EXT }, 85 { "BIG5ETEN*", CS_BIG5_EXT },
84 { "BIG5*", CS_BIG5 }, 86 { "BIG5*", CS_BIG5 },
85 { "GB2312*", CS_GB2312_1980_0 }, 87 { "GB2312*", CS_GB2312_1980_0 },
88 { "GBK*", CS_GBK_0 },
86 { "GB6345*", CS_GB2312_1980_0 }, // slightly different to gb2312?? 89 { "GB6345*", CS_GB2312_1980_0 }, // slightly different to gb2312??
87 { "GB8565*", CS_GB2312_1980_0 }, // a superset of gb2312?? 90 { "GB8565*", CS_GB2312_1980_0 }, // a superset of gb2312??
88 { "GB13000*", CS_UNICODE }, 91 { "GB13000*", CS_UNICODE },
89 { "CNS1164319921", CS_CNS11643_1992_1 }, 92 { "CNS1164319921", CS_CNS11643_1992_1 },
90 { "CNS1164319922", CS_CNS11643_1992_2 }, 93 { "CNS1164319922", CS_CNS11643_1992_2 },
177 180
178//#define ENCODING_KR 181//#define ENCODING_KR
179 182
180#include "table/ksc5601_1987_0.h" 183#include "table/ksc5601_1987_0.h"
181 184
182//#define ENCODING_CN 185//#define ENCODING_ZH
183 186
187#include "table/big5.h"
188#include "table/gbk_0.h"
184#include "table/gb2312_1980_0.h" 189#include "table/gb2312_1980_0.h"
185#include "table/big5.h"
186 190
187//#define ENCODING_CN_EXT 191//#define ENCODING_ZH_EXT
188 192
189#include "table/cns11643_1992_1.h" 193#include "table/cns11643_1992_1.h"
190#include "table/cns11643_1992_2.h" 194#include "table/cns11643_1992_2.h"
191#include "table/cns11643_1992_3.h" 195#include "table/cns11643_1992_3.h"
192#include "table/cns11643_1992_4.h" 196#include "table/cns11643_1992_4.h"
215#if ENCODING_TO_UNICODE 219#if ENCODING_TO_UNICODE
216# define ENC(base) { cs_ ## base ## _from_unicode, cs_ ## base ## _to_unicode } 220# define ENC(base) { cs_ ## base ## _from_unicode, cs_ ## base ## _to_unicode }
217#else 221#else
218# define ENC(base) { cs_ ## base ## _from_unicode } 222# define ENC(base) { cs_ ## base ## _from_unicode }
219#endif 223#endif
220 224
221 225
222// order must match table in encoding.h(!) 226// order must match table in encoding.h(!)
223const rxvt_codeset_conv rxvt_codeset[NUM_CODESETS] = { 227const rxvt_codeset_conv rxvt_codeset[NUM_CODESETS] = {
224 ENC (unknown), 228 ENC (unknown),
225 229
252 ENC (jis0213_2), 256 ENC (jis0213_2),
253 257
254 ENC (ksc5601_1987_0), 258 ENC (ksc5601_1987_0),
255 259
256 ENC (gb2312_1980_0), 260 ENC (gb2312_1980_0),
261 ENC (gbk_0),
257 262
258 ENC (cns11643_1992_1), 263 ENC (cns11643_1992_1),
259 ENC (cns11643_1992_2), 264 ENC (cns11643_1992_2),
260 ENC (cns11643_1992_3), 265 ENC (cns11643_1992_3),
261 ENC (cns11643_1992_4), 266 ENC (cns11643_1992_4),
281 286
282unicode_t 287unicode_t
283rxvt_compose (unicode_t c1, unicode_t c2) 288rxvt_compose (unicode_t c1, unicode_t c2)
284{ 289{
285 int l = 0; 290 int l = 0;
286 int r = sizeof (rxvt_compose_table) / sizeof (rxvt_compose_entry) - 1; 291 int r = ARRAY_LENGTH(rxvt_compose_table) - 1;
287 int m; 292 int m;
288 293
289 while (r > l) 294 while (r >= l)
290 { 295 {
291 m = (l + r) / 2; 296 m = (l + r) / 2;
292 rxvt_compose_entry &c = rxvt_compose_table[m]; 297 rxvt_compose_entry &c = rxvt_compose_table[m];
293 298
294 if (c.c1 < c1 || (c.c1 == c1 && c.c2 < c2)) 299 if (c.c1 < c1 || (c.c1 == c1 && c.c2 < c2))
304 309
305#include "table/category.h" 310#include "table/category.h"
306 311
307bool unicode::is_space (unicode_t c) 312bool unicode::is_space (unicode_t c)
308{ 313{
309 return IS_SPACE (c); 314 return IS_SPACE (c)
315 || c == 0x09; // exclude tabs, too, as we store them in the buffer
310} 316}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines