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.10 by pcg, Sun Mar 14 17:33:07 2004 UTC vs.
Revision 1.18 by root, Wed Aug 4 03:29:28 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>
44 { "KOI8U", CS_KOI8_U }, 66 { "KOI8U", CS_KOI8_U },
45 67
46 { "VISCII*", CS_VISCII }, 68 { "VISCII*", CS_VISCII },
47 69
48 { "JISX0201*", CS_JIS0201_1976_0 }, 70 { "JISX0201*", CS_JIS0201_1976_0 },
71 { "JISC6226*", CS_JIS0208_1990_0 }, // also wrongly matches -1987-0? (check Encode::JP)
49 { "JISX0208*", CS_JIS0208_1983_0 }, // also wrongly matches -1990-0 (check Encode::JP) 72 { "JISX0208*", CS_JIS0208_1990_0 }, // also wrongly matches -1987-0? (check Encode::JP)
50 { "JISX0212*", CS_JIS0212_1990_0 }, 73 { "JISX0212*", CS_JIS0212_1990_0 },
74 { "JISX021320001", CS_JIS0213_1 },
75 { "JISX021320002", CS_JIS0213_2 },
51 { "JISX0221*", CS_UNICODE }, 76 { "JISX0221*", CS_UNICODE }, // _very_ close
52 77
53 { "KSC5601*", CS_KSC5601_1987_0 }, 78 { "KSC5601*", CS_KSC5601_1987_0 },
54 { "KSX1001*", CS_KSC5601_1987_0 }, 79 { "KSX1001*", CS_KSC5601_1987_0 },
55 { "KSC5700*", CS_UNICODE }, // unicode plus extensions 80 { "KSC5700*", CS_UNICODE }, // unicode plus extensions
56 81
112 } while ((++i)->name); 137 } while ((++i)->name);
113 138
114 return CS_UNKNOWN; 139 return CS_UNKNOWN;
115} 140}
116 141
117struct rxvt_codeset_conv_unknown : rxvt_codeset_conv { 142static unicode_t cs_unknown_to_unicode (uint32_t enc) { return NOCHAR; }
118 uint32_t to_unicode (uint32_t enc) const { return NOCHAR; }
119 uint32_t from_unicode (uint32_t unicode) const { return NOCHAR; } 143static uint32_t cs_unknown_from_unicode (unicode_t unicode) { return NOCHAR; }
120} rxvt_codeset_conv_unknown;
121 144
122struct rxvt_codeset_conv_us_ascii : rxvt_codeset_conv { 145static unicode_t cs_unicode_to_unicode (uint32_t enc) { return enc; }
146static uint32_t cs_unicode_from_unicode (unicode_t unicode) { return unicode; }
147
148#define cs_us_ascii_to_unicode cs_unicode_to_unicode
123 uint32_t from_unicode (uint32_t unicode) const { return unicode <= 127 ? unicode : NOCHAR; } 149static uint32_t cs_us_ascii_from_unicode (unicode_t unicode) { return unicode <= 127 ? unicode : NOCHAR; }
124} rxvt_codeset_conv_us_ascii;
125 150
126struct rxvt_codeset_conv_unicode : rxvt_codeset_conv { 151#define cs_us_ascii_to_unicode_16 cs_unicode_to_unicode
127 /* transparent */
128} rxvt_codeset_conv_unicode;
129
130struct rxvt_codeset_conv_unicode_16 : rxvt_codeset_conv {
131 uint32_t to_unicode (uint32_t enc) const { return enc; }
132 uint32_t from_unicode (uint32_t unicode) const { return unicode <= 65535 ? unicode : NOCHAR; } 152static uint32_t cs_unicode_16_from_unicode (unicode_t unicode) { return unicode <= 65535 ? unicode : NOCHAR; }
133} rxvt_codeset_conv_unicode_16;
134 153
135#define ENCODING_DEFAULT 154#define ENCODING_DEFAULT
136 155
137#include "table/iso8859_1.h" 156#include "table/iso8859_1.h"
138#include "table/iso8859_15.h" 157#include "table/iso8859_15.h"
183#include "table/viscii.h" 202#include "table/viscii.h"
184 203
185//#define ENCODING_JP 204//#define ENCODING_JP
186 205
187#include "table/jis0201_1976_0.h" 206#include "table/jis0201_1976_0.h"
188#include "table/jis0208_1983_0.h" 207#include "table/jis0208_1990_0.h"
189#include "table/jis0212_1990_0.h" 208#include "table/jis0212_1990_0.h"
190 209
191//#define ENCODING_JP_EXT 210//#define ENCODING_JP_EXT
192 211
193#include "table/jis0213_1.h" 212#include "table/jis0213_1.h"
194#include "table/jis0213_2.h" 213#include "table/jis0213_2.h"
195 214
215#if ENCODING_TO_UNICODE
216# define ENC(base) { cs_ ## base ## _from_unicode, cs_ ## base ## _to_unicode }
217#else
218# define ENC(base) { cs_ ## base ## _from_unicode }
219#endif
220
221
196// order must match table in encoding.h(!) 222// order must match table in encoding.h(!)
197const rxvt_codeset_conv *rxvt_codeset[NUM_CODESETS] = { 223const rxvt_codeset_conv rxvt_codeset[NUM_CODESETS] = {
198 &rxvt_codeset_conv_unknown, 224 ENC (unknown),
199 225
200 &rxvt_codeset_conv_us_ascii, 226 ENC (us_ascii),
201 227
202 &rxvt_codeset_conv_iso8859_1, 228 ENC (iso8859_1),
203 &rxvt_codeset_conv_iso8859_2, 229 ENC (iso8859_2),
204 &rxvt_codeset_conv_iso8859_3, 230 ENC (iso8859_3),
205 &rxvt_codeset_conv_iso8859_4, 231 ENC (iso8859_4),
206 &rxvt_codeset_conv_iso8859_5, 232 ENC (iso8859_5),
207 &rxvt_codeset_conv_iso8859_6, 233 ENC (iso8859_6),
208 &rxvt_codeset_conv_iso8859_7, 234 ENC (iso8859_7),
209 &rxvt_codeset_conv_iso8859_8, 235 ENC (iso8859_8),
210 &rxvt_codeset_conv_iso8859_9, 236 ENC (iso8859_9),
211 &rxvt_codeset_conv_iso8859_10, 237 ENC (iso8859_10),
212 &rxvt_codeset_conv_iso8859_11, 238 ENC (iso8859_11),
213 &rxvt_codeset_conv_iso8859_13, 239 ENC (iso8859_13),
214 &rxvt_codeset_conv_iso8859_14, 240 ENC (iso8859_14),
215 &rxvt_codeset_conv_iso8859_15, 241 ENC (iso8859_15),
216 &rxvt_codeset_conv_iso8859_16, 242 ENC (iso8859_16),
217 243
218 &rxvt_codeset_conv_koi8_r, 244 ENC (koi8_r),
219 &rxvt_codeset_conv_koi8_u, 245 ENC (koi8_u),
220 246
221 &rxvt_codeset_conv_jis0201_1976_0, 247 ENC (jis0201_1976_0),
222 &rxvt_codeset_conv_jis0208_1983_0, 248 ENC (jis0208_1990_0),
223 &rxvt_codeset_conv_jis0212_1990_0, 249 ENC (jis0212_1990_0),
224 250
225 &rxvt_codeset_conv_jis0213_1, 251 ENC (jis0213_1),
226 &rxvt_codeset_conv_jis0213_2, 252 ENC (jis0213_2),
227 253
228 &rxvt_codeset_conv_ksc5601_1987_0, 254 ENC (ksc5601_1987_0),
229 255
230 &rxvt_codeset_conv_gb2312_1980_0, 256 ENC (gb2312_1980_0),
231 257
232 &rxvt_codeset_conv_cns11643_1992_1, 258 ENC (cns11643_1992_1),
233 &rxvt_codeset_conv_cns11643_1992_2, 259 ENC (cns11643_1992_2),
234 &rxvt_codeset_conv_cns11643_1992_3, 260 ENC (cns11643_1992_3),
235 &rxvt_codeset_conv_cns11643_1992_4, 261 ENC (cns11643_1992_4),
236 &rxvt_codeset_conv_cns11643_1992_5, 262 ENC (cns11643_1992_5),
237 &rxvt_codeset_conv_cns11643_1992_6, 263 ENC (cns11643_1992_6),
238 &rxvt_codeset_conv_cns11643_1992_7, 264 ENC (cns11643_1992_7),
239 &rxvt_codeset_conv_cns11643_1992_f, 265 ENC (cns11643_1992_f),
240 &rxvt_codeset_conv_big5, 266 ENC (big5),
241 &rxvt_codeset_conv_big5_ext, 267 ENC (big5_ext),
242 &rxvt_codeset_conv_big5_plus, 268 ENC (big5_plus),
243 269
244 &rxvt_codeset_conv_viscii, 270 ENC (viscii),
245 271
246 &rxvt_codeset_conv_unicode_16, 272 ENC (unicode_16),
247 &rxvt_codeset_conv_unicode 273 ENC (unicode),
248}; 274};
249 275
250#if ENABLE_COMBINING 276#if ENABLE_COMBINING
251# define ENCODING_COMPOSE 277# define ENCODING_COMPOSE
252#endif 278#endif
253 279
254#include "table/compose.h" 280#include "table/compose.h"
255 281
256uint32_t 282unicode_t
257rxvt_compose (uint32_t c1, uint32_t c2) 283rxvt_compose (unicode_t c1, unicode_t c2)
258{ 284{
259 int l = 0; 285 int l = 0;
260 int r = sizeof (rxvt_compose_table) / sizeof (rxvt_compose_entry) - 1; 286 int r = sizeof (rxvt_compose_table) / sizeof (rxvt_compose_entry) - 1;
261 int m; 287 int m;
262 288
273 return c.r; 299 return c.r;
274 } 300 }
275 301
276 return NOCHAR; 302 return NOCHAR;
277} 303}
304
305#include "table/category.h"
306
307bool unicode::is_space (unicode_t c)
308{
309 return IS_SPACE (c);
310}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines