|
|
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 | |
… | |
… | |
113 | |
138 | |
114 | return CS_UNKNOWN; |
139 | return CS_UNKNOWN; |
115 | } |
140 | } |
116 | |
141 | |
117 | struct rxvt_codeset_conv_unknown : rxvt_codeset_conv { |
142 | struct rxvt_codeset_conv_unknown : rxvt_codeset_conv { |
118 | uint32_t to_unicode (uint32_t enc) const { return NOCHAR; } |
143 | unicode_t to_unicode (uint32_t enc) const { return NOCHAR; } |
119 | uint32_t from_unicode (uint32_t unicode) const { return NOCHAR; } |
144 | uint32_t from_unicode (unicode_t unicode) const { return NOCHAR; } |
120 | } rxvt_codeset_conv_unknown; |
145 | } rxvt_codeset_conv_unknown; |
121 | |
146 | |
122 | struct rxvt_codeset_conv_us_ascii : rxvt_codeset_conv { |
147 | struct rxvt_codeset_conv_us_ascii : rxvt_codeset_conv { |
123 | uint32_t from_unicode (uint32_t unicode) const { return unicode <= 127 ? unicode : NOCHAR; } |
148 | uint32_t from_unicode (unicode_t unicode) const { return unicode <= 127 ? unicode : NOCHAR; } |
124 | } rxvt_codeset_conv_us_ascii; |
149 | } rxvt_codeset_conv_us_ascii; |
125 | |
150 | |
126 | struct rxvt_codeset_conv_unicode : rxvt_codeset_conv { |
151 | struct rxvt_codeset_conv_unicode : rxvt_codeset_conv { |
127 | /* transparent */ |
152 | /* transparent */ |
128 | } rxvt_codeset_conv_unicode; |
153 | } rxvt_codeset_conv_unicode; |
129 | |
154 | |
130 | struct rxvt_codeset_conv_unicode_16 : rxvt_codeset_conv { |
155 | struct rxvt_codeset_conv_unicode_16 : rxvt_codeset_conv { |
131 | uint32_t to_unicode (uint32_t enc) const { return enc; } |
156 | unicode_t to_unicode (uint32_t enc) const { return enc; } |
132 | uint32_t from_unicode (uint32_t unicode) const { return unicode <= 65535 ? unicode : NOCHAR; } |
157 | uint32_t from_unicode (unicode_t unicode) const { return unicode <= 65535 ? unicode : NOCHAR; } |
133 | } rxvt_codeset_conv_unicode_16; |
158 | } rxvt_codeset_conv_unicode_16; |
134 | |
159 | |
135 | #define ENCODING_DEFAULT |
160 | #define ENCODING_DEFAULT |
136 | |
161 | |
137 | #include "table/iso8859_1.h" |
162 | #include "table/iso8859_1.h" |
… | |
… | |
183 | #include "table/viscii.h" |
208 | #include "table/viscii.h" |
184 | |
209 | |
185 | //#define ENCODING_JP |
210 | //#define ENCODING_JP |
186 | |
211 | |
187 | #include "table/jis0201_1976_0.h" |
212 | #include "table/jis0201_1976_0.h" |
188 | #include "table/jis0208_1983_0.h" |
213 | #include "table/jis0208_1990_0.h" |
189 | #include "table/jis0212_1990_0.h" |
214 | #include "table/jis0212_1990_0.h" |
190 | |
215 | |
191 | //#define ENCODING_JP_EXT |
216 | //#define ENCODING_JP_EXT |
192 | |
217 | |
193 | #include "table/jis0213_1.h" |
218 | #include "table/jis0213_1.h" |
… | |
… | |
217 | |
242 | |
218 | &rxvt_codeset_conv_koi8_r, |
243 | &rxvt_codeset_conv_koi8_r, |
219 | &rxvt_codeset_conv_koi8_u, |
244 | &rxvt_codeset_conv_koi8_u, |
220 | |
245 | |
221 | &rxvt_codeset_conv_jis0201_1976_0, |
246 | &rxvt_codeset_conv_jis0201_1976_0, |
222 | &rxvt_codeset_conv_jis0208_1983_0, |
247 | &rxvt_codeset_conv_jis0208_1990_0, |
223 | &rxvt_codeset_conv_jis0212_1990_0, |
248 | &rxvt_codeset_conv_jis0212_1990_0, |
224 | |
249 | |
225 | &rxvt_codeset_conv_jis0213_1, |
250 | &rxvt_codeset_conv_jis0213_1, |
226 | &rxvt_codeset_conv_jis0213_2, |
251 | &rxvt_codeset_conv_jis0213_2, |
227 | |
252 | |
… | |
… | |
251 | # define ENCODING_COMPOSE |
276 | # define ENCODING_COMPOSE |
252 | #endif |
277 | #endif |
253 | |
278 | |
254 | #include "table/compose.h" |
279 | #include "table/compose.h" |
255 | |
280 | |
256 | uint32_t |
281 | unicode_t |
257 | rxvt_compose (uint32_t c1, uint32_t c2) |
282 | rxvt_compose (unicode_t c1, unicode_t c2) |
258 | { |
283 | { |
259 | int l = 0; |
284 | int l = 0; |
260 | int r = sizeof (rxvt_compose_table) / sizeof (rxvt_compose_entry) - 1; |
285 | int r = sizeof (rxvt_compose_table) / sizeof (rxvt_compose_entry) - 1; |
261 | int m; |
286 | int m; |
262 | |
287 | |
… | |
… | |
273 | return c.r; |
298 | return c.r; |
274 | } |
299 | } |
275 | |
300 | |
276 | return NOCHAR; |
301 | return NOCHAR; |
277 | } |
302 | } |
|
|
303 | |
|
|
304 | #include "table/category.h" |
|
|
305 | |
|
|
306 | bool unicode::is_space (unicode_t c) |
|
|
307 | { |
|
|
308 | return IS_SPACE (c); |
|
|
309 | } |