… | |
… | |
137 | } while ((++i)->name); |
137 | } while ((++i)->name); |
138 | |
138 | |
139 | return CS_UNKNOWN; |
139 | return CS_UNKNOWN; |
140 | } |
140 | } |
141 | |
141 | |
142 | struct rxvt_codeset_conv_unknown : rxvt_codeset_conv { |
|
|
143 | unicode_t to_unicode (uint32_t enc) const { return NOCHAR; } |
142 | static unicode_t cs_unknown_to_unicode (uint32_t enc) { return NOCHAR; } |
144 | uint32_t from_unicode (unicode_t unicode) const { return NOCHAR; } |
143 | static uint32_t cs_unknown_from_unicode (unicode_t unicode) { return NOCHAR; } |
145 | } rxvt_codeset_conv_unknown; |
|
|
146 | |
144 | |
147 | struct rxvt_codeset_conv_us_ascii : rxvt_codeset_conv { |
145 | static unicode_t cs_unicode_to_unicode (uint32_t enc) { return enc; } |
|
|
146 | static uint32_t cs_unicode_from_unicode (unicode_t unicode) { return unicode; } |
|
|
147 | |
|
|
148 | #define cs_us_ascii_to_unicode cs_unicode_to_unicode |
148 | uint32_t from_unicode (unicode_t unicode) const { return unicode <= 127 ? unicode : NOCHAR; } |
149 | static uint32_t cs_us_ascii_from_unicode (unicode_t unicode) { return unicode <= 127 ? unicode : NOCHAR; } |
149 | } rxvt_codeset_conv_us_ascii; |
|
|
150 | |
150 | |
151 | struct rxvt_codeset_conv_unicode : rxvt_codeset_conv { |
151 | #define cs_us_ascii_to_unicode_16 cs_unicode_to_unicode |
152 | /* transparent */ |
|
|
153 | } rxvt_codeset_conv_unicode; |
|
|
154 | |
|
|
155 | struct rxvt_codeset_conv_unicode_16 : rxvt_codeset_conv { |
|
|
156 | unicode_t to_unicode (uint32_t enc) const { return enc; } |
|
|
157 | uint32_t from_unicode (unicode_t unicode) const { return unicode <= 65535 ? unicode : NOCHAR; } |
152 | static uint32_t cs_unicode_16_from_unicode (unicode_t unicode) { return unicode <= 65535 ? unicode : NOCHAR; } |
158 | } rxvt_codeset_conv_unicode_16; |
|
|
159 | |
153 | |
160 | #define ENCODING_DEFAULT |
154 | #define ENCODING_DEFAULT |
161 | |
155 | |
162 | #include "table/iso8859_1.h" |
156 | #include "table/iso8859_1.h" |
163 | #include "table/iso8859_15.h" |
157 | #include "table/iso8859_15.h" |
… | |
… | |
183 | |
177 | |
184 | //#define ENCODING_KR |
178 | //#define ENCODING_KR |
185 | |
179 | |
186 | #include "table/ksc5601_1987_0.h" |
180 | #include "table/ksc5601_1987_0.h" |
187 | |
181 | |
188 | //#define ENCODING_CN |
182 | //#define ENCODING_ZH |
189 | |
183 | |
190 | #include "table/gb2312_1980_0.h" |
184 | #include "table/gb2312_1980_0.h" |
191 | #include "table/big5.h" |
185 | #include "table/big5.h" |
192 | |
186 | |
193 | //#define ENCODING_CN_EXT |
187 | //#define ENCODING_ZH_EXT |
194 | |
188 | |
195 | #include "table/cns11643_1992_1.h" |
189 | #include "table/cns11643_1992_1.h" |
196 | #include "table/cns11643_1992_2.h" |
190 | #include "table/cns11643_1992_2.h" |
197 | #include "table/cns11643_1992_3.h" |
191 | #include "table/cns11643_1992_3.h" |
198 | #include "table/cns11643_1992_4.h" |
192 | #include "table/cns11643_1992_4.h" |
… | |
… | |
216 | //#define ENCODING_JP_EXT |
210 | //#define ENCODING_JP_EXT |
217 | |
211 | |
218 | #include "table/jis0213_1.h" |
212 | #include "table/jis0213_1.h" |
219 | #include "table/jis0213_2.h" |
213 | #include "table/jis0213_2.h" |
220 | |
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 | |
221 | // order must match table in encoding.h(!) |
222 | // order must match table in encoding.h(!) |
222 | const rxvt_codeset_conv *rxvt_codeset[NUM_CODESETS] = { |
223 | const rxvt_codeset_conv rxvt_codeset[NUM_CODESETS] = { |
223 | &rxvt_codeset_conv_unknown, |
224 | ENC (unknown), |
224 | |
225 | |
225 | &rxvt_codeset_conv_us_ascii, |
226 | ENC (us_ascii), |
226 | |
227 | |
227 | &rxvt_codeset_conv_iso8859_1, |
228 | ENC (iso8859_1), |
228 | &rxvt_codeset_conv_iso8859_2, |
229 | ENC (iso8859_2), |
229 | &rxvt_codeset_conv_iso8859_3, |
230 | ENC (iso8859_3), |
230 | &rxvt_codeset_conv_iso8859_4, |
231 | ENC (iso8859_4), |
231 | &rxvt_codeset_conv_iso8859_5, |
232 | ENC (iso8859_5), |
232 | &rxvt_codeset_conv_iso8859_6, |
233 | ENC (iso8859_6), |
233 | &rxvt_codeset_conv_iso8859_7, |
234 | ENC (iso8859_7), |
234 | &rxvt_codeset_conv_iso8859_8, |
235 | ENC (iso8859_8), |
235 | &rxvt_codeset_conv_iso8859_9, |
236 | ENC (iso8859_9), |
236 | &rxvt_codeset_conv_iso8859_10, |
237 | ENC (iso8859_10), |
237 | &rxvt_codeset_conv_iso8859_11, |
238 | ENC (iso8859_11), |
238 | &rxvt_codeset_conv_iso8859_13, |
239 | ENC (iso8859_13), |
239 | &rxvt_codeset_conv_iso8859_14, |
240 | ENC (iso8859_14), |
240 | &rxvt_codeset_conv_iso8859_15, |
241 | ENC (iso8859_15), |
241 | &rxvt_codeset_conv_iso8859_16, |
242 | ENC (iso8859_16), |
242 | |
243 | |
243 | &rxvt_codeset_conv_koi8_r, |
244 | ENC (koi8_r), |
244 | &rxvt_codeset_conv_koi8_u, |
245 | ENC (koi8_u), |
245 | |
246 | |
246 | &rxvt_codeset_conv_jis0201_1976_0, |
247 | ENC (jis0201_1976_0), |
247 | &rxvt_codeset_conv_jis0208_1990_0, |
248 | ENC (jis0208_1990_0), |
248 | &rxvt_codeset_conv_jis0212_1990_0, |
249 | ENC (jis0212_1990_0), |
249 | |
250 | |
250 | &rxvt_codeset_conv_jis0213_1, |
251 | ENC (jis0213_1), |
251 | &rxvt_codeset_conv_jis0213_2, |
252 | ENC (jis0213_2), |
252 | |
253 | |
253 | &rxvt_codeset_conv_ksc5601_1987_0, |
254 | ENC (ksc5601_1987_0), |
254 | |
255 | |
255 | &rxvt_codeset_conv_gb2312_1980_0, |
256 | ENC (gb2312_1980_0), |
256 | |
257 | |
257 | &rxvt_codeset_conv_cns11643_1992_1, |
258 | ENC (cns11643_1992_1), |
258 | &rxvt_codeset_conv_cns11643_1992_2, |
259 | ENC (cns11643_1992_2), |
259 | &rxvt_codeset_conv_cns11643_1992_3, |
260 | ENC (cns11643_1992_3), |
260 | &rxvt_codeset_conv_cns11643_1992_4, |
261 | ENC (cns11643_1992_4), |
261 | &rxvt_codeset_conv_cns11643_1992_5, |
262 | ENC (cns11643_1992_5), |
262 | &rxvt_codeset_conv_cns11643_1992_6, |
263 | ENC (cns11643_1992_6), |
263 | &rxvt_codeset_conv_cns11643_1992_7, |
264 | ENC (cns11643_1992_7), |
264 | &rxvt_codeset_conv_cns11643_1992_f, |
265 | ENC (cns11643_1992_f), |
265 | &rxvt_codeset_conv_big5, |
266 | ENC (big5), |
266 | &rxvt_codeset_conv_big5_ext, |
267 | ENC (big5_ext), |
267 | &rxvt_codeset_conv_big5_plus, |
268 | ENC (big5_plus), |
268 | |
269 | |
269 | &rxvt_codeset_conv_viscii, |
270 | ENC (viscii), |
270 | |
271 | |
271 | &rxvt_codeset_conv_unicode_16, |
272 | ENC (unicode_16), |
272 | &rxvt_codeset_conv_unicode |
273 | ENC (unicode), |
273 | }; |
274 | }; |
274 | |
275 | |
275 | #if ENABLE_COMBINING |
276 | #if ENABLE_COMBINING |
276 | # define ENCODING_COMPOSE |
277 | # define ENCODING_COMPOSE |
277 | #endif |
278 | #endif |
… | |
… | |
303 | |
304 | |
304 | #include "table/category.h" |
305 | #include "table/category.h" |
305 | |
306 | |
306 | bool unicode::is_space (unicode_t c) |
307 | bool unicode::is_space (unicode_t c) |
307 | { |
308 | { |
308 | return IS_SPACE (c); |
309 | return IS_SPACE (c) |
|
|
310 | || c == 0x09; // exclude tabs, too, as we store them in the buffer |
309 | } |
311 | } |