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.3 by pcg, Wed Mar 3 17:15:49 2004 UTC vs.
Revision 1.16 by pcg, Thu Apr 8 20:31:45 2004 UTC

1/*--------------------------------*-C-*---------------------------------*
2 * File: encoding.C
3 *----------------------------------------------------------------------*
4 *
5 * All portions of code are copyright by their respective author/s.
6 * Copyright (c) 2003-2004 Marc Lehmann <pcg@goof.com>
7 *
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
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 *----------------------------------------------------------------------*/
22
1#include "../config.h" 23#include "../config.h"
2 24
3#include "encoding.h" 25#include "encoding.h"
4 26
5#include <cstdlib> 27#include <cstdlib>
26 { "ISO885914", CS_ISO8859_14 }, 48 { "ISO885914", CS_ISO8859_14 },
27 { "ISO885915", CS_ISO8859_15 }, 49 { "ISO885915", CS_ISO8859_15 },
28 { "FCD885915", CS_ISO8859_15 }, 50 { "FCD885915", CS_ISO8859_15 },
29 { "ISO885916", CS_ISO8859_16 }, 51 { "ISO885916", CS_ISO8859_16 },
30 52
53 { "TIS620*", CS_ISO8859_11 }, // close enough
54
31 { "ISO10646*", CS_UNICODE }, 55 { "ISO10646*", CS_UNICODE },
32 { "UNICODE", CS_UNICODE }, 56 { "UNICODE", CS_UNICODE },
33 { "UTF8", CS_UNICODE }, 57 { "UTF8", CS_UNICODE },
34 58
35 { "ASCII", CS_US_ASCII }, 59 { "ASCII", CS_US_ASCII },
40 { "GOST1976874*", CS_KOI8_R }, 64 { "GOST1976874*", CS_KOI8_R },
41 { "KOI8RU", CS_KOI8_U }, 65 { "KOI8RU", CS_KOI8_U },
42 { "KOI8U", CS_KOI8_U }, 66 { "KOI8U", CS_KOI8_U },
43 67
44 { "VISCII*", CS_VISCII }, 68 { "VISCII*", CS_VISCII },
45 { "TIS62025291", CS_VISCII }, // close enough
46 69
47 { "JISX0201*", CS_JIS0201_1976_0 }, 70 { "JISX0201*", CS_JIS0201_1976_0 },
48 { "JISX0208*", CS_JIS0208_1983_0 }, // also wrongly matches -1990-0 (check Encode::JP) 71 { "JISX0208*", CS_JIS0208_1990_0 }, // also wrongly matches -1987-0? (check Encode::JP)
49 { "JISX0212*", CS_JIS0212_1990_0 }, 72 { "JISX0212*", CS_JIS0212_1990_0 },
73 { "JISX021320001", CS_JIS0213_1 },
74 { "JISX021320002", CS_JIS0213_2 },
50 { "JISX0221*", CS_UNICODE }, 75 { "JISX0221*", CS_UNICODE }, // _very_ close
51 76
52 { "KSC5601*", CS_KSC5601_1987_0 }, 77 { "KSC5601*", CS_KSC5601_1987_0 },
53 { "KSX1001*", CS_KSC5601_1987_0 }, 78 { "KSX1001*", CS_KSC5601_1987_0 },
54 { "KSC5700*", CS_UNICODE }, // unicode plus extensions 79 { "KSC5700*", CS_UNICODE }, // unicode plus extensions
55 80
112 137
113 return CS_UNKNOWN; 138 return CS_UNKNOWN;
114} 139}
115 140
116struct rxvt_codeset_conv_unknown : rxvt_codeset_conv { 141struct rxvt_codeset_conv_unknown : rxvt_codeset_conv {
117 uint32_t to_unicode (uint32_t enc) const { return NOCHAR; } 142 unicode_t to_unicode (uint32_t enc) const { return NOCHAR; }
118 uint32_t from_unicode (uint32_t unicode) const { return NOCHAR; } 143 uint32_t from_unicode (unicode_t unicode) const { return NOCHAR; }
119} rxvt_codeset_conv_unknown; 144} rxvt_codeset_conv_unknown;
120 145
121struct rxvt_codeset_conv_us_ascii : rxvt_codeset_conv { 146struct rxvt_codeset_conv_us_ascii : rxvt_codeset_conv {
122 uint32_t from_unicode (uint32_t unicode) const { return unicode <= 127 ? unicode : NOCHAR; } 147 uint32_t from_unicode (unicode_t unicode) const { return unicode <= 127 ? unicode : NOCHAR; }
123} rxvt_codeset_conv_us_ascii; 148} rxvt_codeset_conv_us_ascii;
124 149
125struct rxvt_codeset_conv_unicode : rxvt_codeset_conv { 150struct rxvt_codeset_conv_unicode : rxvt_codeset_conv {
126 /* transparent */ 151 /* transparent */
127} rxvt_codeset_conv_unicode; 152} rxvt_codeset_conv_unicode;
128 153
129struct rxvt_codeset_conv_unicode_16 : rxvt_codeset_conv { 154struct rxvt_codeset_conv_unicode_16 : rxvt_codeset_conv {
130 uint32_t to_unicode (uint32_t enc) const { return enc; } 155 unicode_t to_unicode (uint32_t enc) const { return enc; }
131 uint32_t from_unicode (uint32_t unicode) const { return unicode <= 65535 ? unicode : NOCHAR; } 156 uint32_t from_unicode (unicode_t unicode) const { return unicode <= 65535 ? unicode : NOCHAR; }
132} rxvt_codeset_conv_unicode_16; 157} rxvt_codeset_conv_unicode_16;
133
134/* block character set, must conform to the dec special pseudofont in defaultfont.C */
135struct rxvt_codeset_conv_special : rxvt_codeset_conv {
136 uint32_t to_unicode (uint32_t enc) const {
137 return enc;
138 }
139
140 uint32_t from_unicode (uint32_t unicode) const {
141 return unicode;
142 }
143} rxvt_codeset_conv_special;
144 158
145#define ENCODING_DEFAULT 159#define ENCODING_DEFAULT
146 160
147#include "table/iso8859_1.h" 161#include "table/iso8859_1.h"
148#include "table/iso8859_15.h" 162#include "table/iso8859_15.h"
193#include "table/viscii.h" 207#include "table/viscii.h"
194 208
195//#define ENCODING_JP 209//#define ENCODING_JP
196 210
197#include "table/jis0201_1976_0.h" 211#include "table/jis0201_1976_0.h"
198#include "table/jis0208_1983_0.h" 212#include "table/jis0208_1990_0.h"
199#include "table/jis0212_1990_0.h" 213#include "table/jis0212_1990_0.h"
200 214
201//#define ENCODING_JP_EXT 215//#define ENCODING_JP_EXT
202 216
203#include "table/jis0213_1.h" 217#include "table/jis0213_1.h"
204#include "table/jis0213_2.h" 218#include "table/jis0213_2.h"
205 219
206// order must match table in encoding.h(!) 220// order must match table in encoding.h(!)
207const rxvt_codeset_conv *rxvt_codeset[NUM_CODESETS] = { 221const rxvt_codeset_conv *rxvt_codeset[NUM_CODESETS] = {
208 &rxvt_codeset_conv_unknown, 222 &rxvt_codeset_conv_unknown,
209 &rxvt_codeset_conv_special,
210 223
211 &rxvt_codeset_conv_us_ascii, 224 &rxvt_codeset_conv_us_ascii,
212 225
213 &rxvt_codeset_conv_iso8859_1, 226 &rxvt_codeset_conv_iso8859_1,
214 &rxvt_codeset_conv_iso8859_2, 227 &rxvt_codeset_conv_iso8859_2,
228 241
229 &rxvt_codeset_conv_koi8_r, 242 &rxvt_codeset_conv_koi8_r,
230 &rxvt_codeset_conv_koi8_u, 243 &rxvt_codeset_conv_koi8_u,
231 244
232 &rxvt_codeset_conv_jis0201_1976_0, 245 &rxvt_codeset_conv_jis0201_1976_0,
233 &rxvt_codeset_conv_jis0208_1983_0, 246 &rxvt_codeset_conv_jis0208_1990_0,
234 &rxvt_codeset_conv_jis0212_1990_0, 247 &rxvt_codeset_conv_jis0212_1990_0,
235 248
236 &rxvt_codeset_conv_jis0213_1, 249 &rxvt_codeset_conv_jis0213_1,
237 &rxvt_codeset_conv_jis0213_2, 250 &rxvt_codeset_conv_jis0213_2,
238 251
256 269
257 &rxvt_codeset_conv_unicode_16, 270 &rxvt_codeset_conv_unicode_16,
258 &rxvt_codeset_conv_unicode 271 &rxvt_codeset_conv_unicode
259}; 272};
260 273
274#if ENABLE_COMBINING
275# define ENCODING_COMPOSE
276#endif
277
278#include "table/compose.h"
279
280unicode_t
281rxvt_compose (unicode_t c1, unicode_t c2)
282{
283 int l = 0;
284 int r = sizeof (rxvt_compose_table) / sizeof (rxvt_compose_entry) - 1;
285 int m;
286
287 while (r > l)
288 {
289 m = (l + r) / 2;
290 rxvt_compose_entry &c = rxvt_compose_table[m];
291
292 if (c.c1 < c1 || (c.c1 == c1 && c.c2 < c2))
293 l = m + 1;
294 else if (c.c1 > c1 || (c.c1 == c1 && c.c2 > c2))
295 r = m - 1;
296 else
297 return c.r;
298 }
299
300 return NOCHAR;
301}
302
303#include "table/category.h"
304
305bool unicode::is_space (unicode_t c)
306{
307 return IS_SPACE (c);
308}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines