1 /* -*- c-basic-offset:2; tab-width:2; indent-tabs-mode:nil -*- */
2 
3 /*
4  * !!!NOTICE!!!
5  *
6  * ISO8859_N msb bit is 0 in mef , and including 0x20 and 0x7f.
7  */
8 
9 #include "../src/ef_ucs4_iso8859.h"
10 
11 #include <string.h>
12 #include <pobl/bl_debug.h>
13 
14 #include "table/ef_iso8859_2_r_to_ucs4.table"
15 #include "table/ef_iso8859_3_r_to_ucs4.table"
16 #include "table/ef_iso8859_4_r_to_ucs4.table"
17 #include "table/ef_iso8859_10_r_to_ucs4.table"
18 #include "table/ef_iso8859_13_r_to_ucs4.table"
19 #include "table/ef_iso8859_14_r_to_ucs4.table"
20 #include "table/ef_iso8859_16_r_to_ucs4.table"
21 
22 #include "table/ef_ucs4_to_iso8859_2_r.table"
23 #include "table/ef_ucs4_to_iso8859_3_r.table"
24 #include "table/ef_ucs4_to_iso8859_4_r.table"
25 #include "table/ef_ucs4_to_iso8859_10_r.table"
26 #include "table/ef_ucs4_to_iso8859_13_r.table"
27 #include "table/ef_ucs4_to_iso8859_14_r.table"
28 #include "table/ef_ucs4_to_iso8859_16_r.table"
29 
30 #include "../src/ef_ucs4_tcvn5712_1.h"
31 
32 /* --- static functions --- */
33 
convert_ucs4_to_iso8859_r_common(ef_char_t * non_ucs,u_int32_t ucs4_code,ef_charset_t cs)34 static int convert_ucs4_to_iso8859_r_common(ef_char_t *non_ucs, u_int32_t ucs4_code,
35                                             ef_charset_t cs) {
36   if (!(0xa0 <= ucs4_code && ucs4_code <= 0xff)) {
37     return 0;
38   }
39 
40   non_ucs->ch[0] = ucs4_code - 0x80;
41   non_ucs->size = 1;
42   non_ucs->cs = cs;
43   non_ucs->property = 0;
44 
45   return 1;
46 }
47 
convert_iso8859_r_common_to_ucs4(ef_char_t * ucs4,u_int16_t iso8859_code)48 static int convert_iso8859_r_common_to_ucs4(ef_char_t *ucs4, u_int16_t iso8859_code) {
49   if (!(0x20 <= iso8859_code && iso8859_code <= 0x7f)) {
50     return 0;
51   }
52 
53   ucs4->ch[0] = 0x0;
54   ucs4->ch[1] = 0x0;
55   ucs4->ch[2] = 0x0;
56   ucs4->ch[3] = iso8859_code + 0x80;
57   ucs4->size = 4;
58   ucs4->cs = ISO10646_UCS4_1;
59   ucs4->property = 0;
60 
61   return 1;
62 }
63 
64 /* --- global functions --- */
65 
ef_map_ucs4_to_iso8859_1_r(ef_char_t * non_ucs,u_int32_t ucs4_code)66 int ef_map_ucs4_to_iso8859_1_r(ef_char_t *non_ucs, u_int32_t ucs4_code) {
67   return convert_ucs4_to_iso8859_r_common(non_ucs, ucs4_code, ISO8859_1_R);
68 }
69 
ef_map_ucs4_to_iso8859_2_r(ef_char_t * non_ucs,u_int32_t ucs4_code)70 int ef_map_ucs4_to_iso8859_2_r(ef_char_t *non_ucs, u_int32_t ucs4_code) {
71   u_int8_t c;
72 
73   if ((c = CONV_UCS4_TO_ISO8859_2_R(ucs4_code))) {
74     non_ucs->ch[0] = c - 0x80;
75     non_ucs->size = 1;
76     non_ucs->cs = ISO8859_2_R;
77     non_ucs->property = 0;
78 
79     return 1;
80   }
81 
82   return 0;
83 }
84 
ef_map_ucs4_to_iso8859_3_r(ef_char_t * non_ucs,u_int32_t ucs4_code)85 int ef_map_ucs4_to_iso8859_3_r(ef_char_t *non_ucs, u_int32_t ucs4_code) {
86   u_int8_t c;
87 
88   if ((c = CONV_UCS4_TO_ISO8859_3_R(ucs4_code))) {
89     non_ucs->ch[0] = c - 0x80;
90     non_ucs->size = 1;
91     non_ucs->cs = ISO8859_3_R;
92     non_ucs->property = 0;
93 
94     return 1;
95   }
96 
97   return 0;
98 }
99 
ef_map_ucs4_to_iso8859_4_r(ef_char_t * non_ucs,u_int32_t ucs4_code)100 int ef_map_ucs4_to_iso8859_4_r(ef_char_t *non_ucs, u_int32_t ucs4_code) {
101   u_int8_t c;
102 
103   if ((c = CONV_UCS4_TO_ISO8859_4_R(ucs4_code))) {
104     non_ucs->ch[0] = c - 0x80;
105     non_ucs->size = 1;
106     non_ucs->cs = ISO8859_4_R;
107     non_ucs->property = 0;
108 
109     return 1;
110   }
111 
112   return 0;
113 }
114 
ef_map_ucs4_to_iso8859_5_r(ef_char_t * non_ucs,u_int32_t ucs4_code)115 int ef_map_ucs4_to_iso8859_5_r(ef_char_t *non_ucs, u_int32_t ucs4_code) {
116   if (ucs4_code == 0x2116) {
117     non_ucs->ch[0] = 0x70;
118   } else if ((0x0401 <= ucs4_code && ucs4_code <= 0x040c) ||
119              (0x040e <= ucs4_code && ucs4_code <= 0x044f) ||
120              (0x0451 <= ucs4_code && ucs4_code <= 0x045c) ||
121              (0x045e <= ucs4_code && ucs4_code <= 0x045f)) {
122     non_ucs->ch[0] = (ucs4_code & 0x00ff) + 0x20;
123   } else {
124     return convert_ucs4_to_iso8859_r_common(non_ucs, ucs4_code, ISO8859_5_R);
125   }
126 
127   non_ucs->size = 1;
128   non_ucs->cs = ISO8859_5_R;
129   non_ucs->property = 0;
130 
131   return 1;
132 }
133 
ef_map_ucs4_to_iso8859_6_r(ef_char_t * non_ucs,u_int32_t ucs4_code)134 int ef_map_ucs4_to_iso8859_6_r(ef_char_t *non_ucs, u_int32_t ucs4_code) {
135   if (ucs4_code == 0x060c) {
136     non_ucs->ch[0] = 0x2c;
137   } else if (0x061b <= ucs4_code && ucs4_code <= 0x0652) {
138     non_ucs->ch[0] = (ucs4_code + 0x20) & 0xff;
139   } else {
140     return convert_ucs4_to_iso8859_r_common(non_ucs, ucs4_code, ISO8859_6_R);
141   }
142 
143   non_ucs->size = 1;
144   non_ucs->cs = ISO8859_6_R;
145   non_ucs->property = 0;
146 
147   return 1;
148 }
149 
ef_map_ucs4_to_iso8859_7_r(ef_char_t * non_ucs,u_int32_t ucs4_code)150 int ef_map_ucs4_to_iso8859_7_r(ef_char_t *non_ucs, u_int32_t ucs4_code) {
151   if (ucs4_code == 0x2015) {
152     non_ucs->ch[0] = 0x2f;
153   } else if (0x2018 <= ucs4_code && ucs4_code <= 0x2019) {
154     non_ucs->ch[0] = 0x21 + (ucs4_code - 0x2018);
155   } else if ((0x0384 <= ucs4_code && ucs4_code <= 0x0386) ||
156              (0x0388 <= ucs4_code && ucs4_code <= 0x038a) || (ucs4_code == 0x038c) ||
157              (0x038e <= ucs4_code && ucs4_code <= 0x03ce)) {
158     non_ucs->ch[0] = (ucs4_code - 0x50) & 0x00ff;
159   } else {
160     return convert_ucs4_to_iso8859_r_common(non_ucs, ucs4_code, ISO8859_7_R);
161   }
162 
163   non_ucs->size = 1;
164   non_ucs->cs = ISO8859_7_R;
165   non_ucs->property = 0;
166 
167   return 1;
168 }
169 
ef_map_ucs4_to_iso8859_8_r(ef_char_t * non_ucs,u_int32_t ucs4_code)170 int ef_map_ucs4_to_iso8859_8_r(ef_char_t *non_ucs, u_int32_t ucs4_code) {
171   if (ucs4_code == 0x2017) {
172     non_ucs->ch[0] = 0x5f;
173   } else if (0x05d0 <= ucs4_code && ucs4_code <= 0x05ea) {
174     non_ucs->ch[0] = (ucs4_code - 0x70) & 0xff;
175   } else if (0x200e <= ucs4_code && ucs4_code <= 0x200f) {
176     non_ucs->ch[0] = 0x7d + (ucs4_code - 0x200e);
177   } else {
178     return convert_ucs4_to_iso8859_r_common(non_ucs, ucs4_code, ISO8859_8_R);
179   }
180 
181   non_ucs->size = 1;
182   non_ucs->cs = ISO8859_8_R;
183   non_ucs->property = 0;
184 
185   return 1;
186 }
187 
ef_map_ucs4_to_iso8859_9_r(ef_char_t * non_ucs,u_int32_t ucs4_code)188 int ef_map_ucs4_to_iso8859_9_r(ef_char_t *non_ucs, u_int32_t ucs4_code) {
189   if (ucs4_code == 0x011e) {
190     non_ucs->ch[0] = 0x50;
191   } else if (ucs4_code == 0x0130) {
192     non_ucs->ch[0] = 0x5d;
193   } else if (ucs4_code == 0x015e) {
194     non_ucs->ch[0] = 0x5e;
195   } else if (ucs4_code == 0x011f) {
196     non_ucs->ch[0] = 0x70;
197   } else if (ucs4_code == 0x0131) {
198     non_ucs->ch[0] = 0x7d;
199   } else if (ucs4_code == 0x015f) {
200     non_ucs->ch[0] = 0x7e;
201   } else {
202     return convert_ucs4_to_iso8859_r_common(non_ucs, ucs4_code, ISO8859_9_R);
203   }
204 
205   non_ucs->size = 1;
206   non_ucs->cs = ISO8859_9_R;
207   non_ucs->property = 0;
208 
209   return 1;
210 }
211 
ef_map_ucs4_to_iso8859_10_r(ef_char_t * non_ucs,u_int32_t ucs4_code)212 int ef_map_ucs4_to_iso8859_10_r(ef_char_t *non_ucs, u_int32_t ucs4_code) {
213   u_int8_t c;
214 
215   if ((c = CONV_UCS4_TO_ISO8859_10_R(ucs4_code))) {
216     non_ucs->ch[0] = c - 0x80;
217     non_ucs->size = 1;
218     non_ucs->cs = ISO8859_10_R;
219     non_ucs->property = 0;
220 
221     return 1;
222   }
223 
224   return 0;
225 }
226 
ef_map_ucs4_to_tis620_2533(ef_char_t * non_ucs,u_int32_t ucs4_code)227 int ef_map_ucs4_to_tis620_2533(ef_char_t *non_ucs, u_int32_t ucs4_code) {
228   if (ucs4_code == 0xa0) {
229     non_ucs->ch[0] = 0x20;
230   } else if (0xe01 <= ucs4_code && ucs4_code <= 0xe5f) {
231     non_ucs->ch[0] = ucs4_code - 0xde0;
232   }
233 #if 0
234   else if (0xe60 <= ucs4_code && ucs4_code <= 0x7f) {
235     /* this region is removed between UNICODDE 1.0 and UNICODE 1.1. */
236   }
237 #endif
238   else {
239     return 0;
240   }
241 
242   non_ucs->size = 1;
243   non_ucs->cs = TIS620_2533;
244   non_ucs->property = 0;
245 
246   return 1;
247 }
248 
ef_map_ucs4_to_iso8859_13_r(ef_char_t * non_ucs,u_int32_t ucs4_code)249 int ef_map_ucs4_to_iso8859_13_r(ef_char_t *non_ucs, u_int32_t ucs4_code) {
250   u_int8_t c;
251 
252   if ((c = CONV_UCS4_TO_ISO8859_13_R(ucs4_code))) {
253     non_ucs->ch[0] = c - 0x80;
254     non_ucs->size = 1;
255     non_ucs->cs = ISO8859_13_R;
256     non_ucs->property = 0;
257 
258     return 1;
259   }
260 
261   return 0;
262 }
263 
ef_map_ucs4_to_iso8859_14_r(ef_char_t * non_ucs,u_int32_t ucs4_code)264 int ef_map_ucs4_to_iso8859_14_r(ef_char_t *non_ucs, u_int32_t ucs4_code) {
265   u_int8_t c;
266 
267   if ((c = CONV_UCS4_TO_ISO8859_14_R(ucs4_code))) {
268     non_ucs->ch[0] = c - 0x80;
269     non_ucs->size = 1;
270     non_ucs->cs = ISO8859_14_R;
271     non_ucs->property = 0;
272 
273     return 1;
274   }
275 
276   return 0;
277 }
278 
ef_map_ucs4_to_iso8859_15_r(ef_char_t * non_ucs,u_int32_t ucs4_code)279 int ef_map_ucs4_to_iso8859_15_r(ef_char_t *non_ucs, u_int32_t ucs4_code) {
280   if (ucs4_code == 0x20ac) {
281     non_ucs->ch[0] = 0x24;
282   } else if (ucs4_code == 0x0160) {
283     non_ucs->ch[0] = 0x26;
284   } else if (ucs4_code == 0x0161) {
285     non_ucs->ch[0] = 0x28;
286   } else if (ucs4_code == 0x017d) {
287     non_ucs->ch[0] = 0x34;
288   } else if (ucs4_code == 0x017e) {
289     non_ucs->ch[0] = 0x38;
290   } else if (ucs4_code == 0x0152 || ucs4_code == 0x0153) {
291     non_ucs->ch[0] = 0x3c + (ucs4_code - 0x0152);
292   } else if (ucs4_code == 0x0178) {
293     non_ucs->ch[0] = 0x3e;
294   } else {
295     return convert_ucs4_to_iso8859_r_common(non_ucs, ucs4_code, ISO8859_15_R);
296   }
297 
298   non_ucs->size = 1;
299   non_ucs->cs = ISO8859_15_R;
300   non_ucs->property = 0;
301 
302   return 1;
303 }
304 
ef_map_ucs4_to_iso8859_16_r(ef_char_t * non_ucs,u_int32_t ucs4_code)305 int ef_map_ucs4_to_iso8859_16_r(ef_char_t *non_ucs, u_int32_t ucs4_code) {
306   u_int8_t c;
307 
308   if ((c = CONV_UCS4_TO_ISO8859_16_R(ucs4_code))) {
309     non_ucs->ch[0] = c - 0x80;
310     non_ucs->size = 1;
311     non_ucs->cs = ISO8859_16_R;
312     non_ucs->property = 0;
313 
314     return 1;
315   }
316 
317   return 0;
318 }
319 
ef_map_ucs4_to_tcvn5712_3_1993(ef_char_t * non_ucs,u_int32_t ucs4_code)320 int ef_map_ucs4_to_tcvn5712_3_1993(ef_char_t *non_ucs, u_int32_t ucs4_code) {
321   if (!ef_map_ucs4_to_tcvn5712_1_1993(non_ucs, ucs4_code)) {
322     return 0;
323   }
324 
325   if (non_ucs->ch[0] < 0xa0) {
326     return 0;
327   }
328 
329   non_ucs->ch[0] -= 0x80;
330   non_ucs->size = 1;
331   non_ucs->cs = TCVN5712_3_1993;
332   non_ucs->property = 0;
333 
334   return 1;
335 }
336 
ef_map_iso8859_1_r_to_ucs4(ef_char_t * ucs4,u_int16_t iso8859_code)337 int ef_map_iso8859_1_r_to_ucs4(ef_char_t *ucs4, u_int16_t iso8859_code) {
338   return convert_iso8859_r_common_to_ucs4(ucs4, iso8859_code);
339 }
340 
ef_map_iso8859_2_r_to_ucs4(ef_char_t * ucs4,u_int16_t iso8859_code)341 int ef_map_iso8859_2_r_to_ucs4(ef_char_t *ucs4, u_int16_t iso8859_code) {
342   u_int32_t c;
343 
344   if ((c = CONV_ISO8859_2_R_TO_UCS4(iso8859_code + 0x80))) {
345     ef_int_to_bytes(ucs4->ch, 4, c);
346     ucs4->size = 4;
347     ucs4->cs = ISO10646_UCS4_1;
348     ucs4->property = 0;
349 
350     return 1;
351   }
352 
353   return 0;
354 }
355 
ef_map_iso8859_3_r_to_ucs4(ef_char_t * ucs4,u_int16_t iso8859_code)356 int ef_map_iso8859_3_r_to_ucs4(ef_char_t *ucs4, u_int16_t iso8859_code) {
357   u_int32_t c;
358 
359   if ((c = CONV_ISO8859_3_R_TO_UCS4(iso8859_code + 0x80))) {
360     ef_int_to_bytes(ucs4->ch, 4, c);
361     ucs4->size = 4;
362     ucs4->cs = ISO10646_UCS4_1;
363     ucs4->property = 0;
364 
365     return 1;
366   }
367 
368   return 0;
369 }
370 
ef_map_iso8859_4_r_to_ucs4(ef_char_t * ucs4,u_int16_t iso8859_code)371 int ef_map_iso8859_4_r_to_ucs4(ef_char_t *ucs4, u_int16_t iso8859_code) {
372   u_int32_t c;
373 
374   if ((c = CONV_ISO8859_4_R_TO_UCS4(iso8859_code + 0x80))) {
375     ef_int_to_bytes(ucs4->ch, 4, c);
376     ucs4->size = 4;
377     ucs4->cs = ISO10646_UCS4_1;
378     ucs4->property = 0;
379 
380     return 1;
381   }
382 
383   return 0;
384 }
385 
ef_map_iso8859_5_r_to_ucs4(ef_char_t * ucs4,u_int16_t iso8859_code)386 int ef_map_iso8859_5_r_to_ucs4(ef_char_t *ucs4, u_int16_t iso8859_code) {
387   if (iso8859_code == 0x70) {
388     ucs4->ch[2] = 0x21;
389     ucs4->ch[3] = 0x16;
390   } else if ((0x21 <= iso8859_code && iso8859_code <= 0x2c) ||
391              (0x2e <= iso8859_code && iso8859_code <= 0x6f) ||
392              (0x71 <= iso8859_code && iso8859_code <= 0x7c) ||
393              (0x7e <= iso8859_code && iso8859_code <= 0x7f)) {
394     ucs4->ch[2] = 0x04;
395     ucs4->ch[3] = iso8859_code - 0x20;
396   } else {
397     return convert_iso8859_r_common_to_ucs4(ucs4, iso8859_code);
398   }
399 
400   ucs4->ch[0] = 0x0;
401   ucs4->ch[1] = 0x0;
402   ucs4->size = 4;
403   ucs4->cs = ISO10646_UCS4_1;
404   ucs4->property = 0;
405 
406   return 1;
407 }
408 
ef_map_iso8859_6_r_to_ucs4(ef_char_t * ucs4,u_int16_t iso8859_code)409 int ef_map_iso8859_6_r_to_ucs4(ef_char_t *ucs4, u_int16_t iso8859_code) {
410   if (iso8859_code == 0x2c) {
411     ucs4->ch[2] = 0x06;
412     ucs4->ch[3] = 0x0c;
413   } else if (0x3b <= iso8859_code && iso8859_code <= 0x72) {
414     ucs4->ch[2] = 0x06;
415     ucs4->ch[3] = (iso8859_code - 0x20) & 0xff;
416   } else {
417     return convert_iso8859_r_common_to_ucs4(ucs4, iso8859_code);
418   }
419 
420   ucs4->ch[0] = 0x0;
421   ucs4->ch[1] = 0x0;
422   ucs4->size = 4;
423   ucs4->cs = ISO10646_UCS4_1;
424   ucs4->property = 0;
425 
426   return 1;
427 }
428 
ef_map_iso8859_7_r_to_ucs4(ef_char_t * ucs4,u_int16_t iso8859_code)429 int ef_map_iso8859_7_r_to_ucs4(ef_char_t *ucs4, u_int16_t iso8859_code) {
430   if (0x21 <= iso8859_code && iso8859_code <= 0x22) {
431     ucs4->ch[2] = 0x20;
432     ucs4->ch[3] = 0x18 + (iso8859_code - 0x21);
433   } else if (iso8859_code == 0x2f) {
434     ucs4->ch[2] = 0x20;
435     ucs4->ch[3] = 0x15;
436   } else if ((0x34 <= iso8859_code && iso8859_code <= 0x36) ||
437              (0x38 <= iso8859_code && iso8859_code <= 0x3a) || (0x3c == iso8859_code) ||
438              (0x3e <= iso8859_code && iso8859_code <= 0x7e)) {
439     ucs4->ch[2] = 0x03;
440     ucs4->ch[3] = iso8859_code + 0x50;
441   } else {
442     return convert_iso8859_r_common_to_ucs4(ucs4, iso8859_code);
443   }
444 
445   ucs4->ch[0] = 0x0;
446   ucs4->ch[1] = 0x0;
447   ucs4->size = 4;
448   ucs4->cs = ISO10646_UCS4_1;
449   ucs4->property = 0;
450 
451   return 1;
452 }
453 
ef_map_iso8859_8_r_to_ucs4(ef_char_t * ucs4,u_int16_t iso8859_code)454 int ef_map_iso8859_8_r_to_ucs4(ef_char_t *ucs4, u_int16_t iso8859_code) {
455   if (iso8859_code == 0xdf) {
456     ucs4->ch[2] = 0x20;
457     ucs4->ch[3] = 0x17;
458   } else if (0x60 <= iso8859_code && iso8859_code <= 0x7a) {
459     ucs4->ch[2] = 0x05;
460     ucs4->ch[3] = iso8859_code + 0x70;
461   } else if (0x7d <= iso8859_code && iso8859_code <= 0x7e) {
462     ucs4->ch[2] = 0x20;
463     ucs4->ch[3] = 0x0e + (iso8859_code - 0x7d);
464   } else {
465     return convert_iso8859_r_common_to_ucs4(ucs4, iso8859_code);
466   }
467 
468   ucs4->ch[0] = 0x0;
469   ucs4->ch[1] = 0x0;
470   ucs4->size = 4;
471   ucs4->cs = ISO10646_UCS4_1;
472   ucs4->property = 0;
473 
474   return 1;
475 }
476 
ef_map_iso8859_9_r_to_ucs4(ef_char_t * ucs4,u_int16_t iso8859_code)477 int ef_map_iso8859_9_r_to_ucs4(ef_char_t *ucs4, u_int16_t iso8859_code) {
478   if (iso8859_code == 0x50) {
479     ucs4->ch[2] = 0x01;
480     ucs4->ch[3] = 0x1e;
481   } else if (iso8859_code == 0x5d) {
482     ucs4->ch[2] = 0x01;
483     ucs4->ch[3] = 0x30;
484   } else if (iso8859_code == 0x5e) {
485     ucs4->ch[2] = 0x01;
486     ucs4->ch[3] = 0x5e;
487   } else if (iso8859_code == 0x70) {
488     ucs4->ch[2] = 0x01;
489     ucs4->ch[3] = 0x1f;
490   } else if (iso8859_code == 0x7d) {
491     ucs4->ch[2] = 0x01;
492     ucs4->ch[3] = 0x31;
493   } else if (iso8859_code == 0x7e) {
494     ucs4->ch[2] = 0x01;
495     ucs4->ch[3] = 0x5f;
496   } else {
497     return convert_iso8859_r_common_to_ucs4(ucs4, iso8859_code);
498   }
499 
500   ucs4->ch[0] = 0x0;
501   ucs4->ch[1] = 0x0;
502 
503   ucs4->size = 4;
504   ucs4->cs = ISO10646_UCS4_1;
505   ucs4->property = 0;
506 
507   return 1;
508 }
509 
ef_map_iso8859_10_r_to_ucs4(ef_char_t * ucs4,u_int16_t iso8859_code)510 int ef_map_iso8859_10_r_to_ucs4(ef_char_t *ucs4, u_int16_t iso8859_code) {
511   u_int32_t c;
512 
513   if ((c = CONV_ISO8859_10_R_TO_UCS4(iso8859_code + 0x80))) {
514     ef_int_to_bytes(ucs4->ch, 4, c);
515     ucs4->size = 4;
516     ucs4->cs = ISO10646_UCS4_1;
517     ucs4->property = 0;
518 
519     return 1;
520   }
521 
522   return 0;
523 }
524 
ef_map_tis620_2533_to_ucs4(ef_char_t * ucs4,u_int16_t tis620_code)525 int ef_map_tis620_2533_to_ucs4(ef_char_t *ucs4, u_int16_t tis620_code) {
526   if (0x20 == tis620_code) {
527     ucs4->ch[0] = 0x0;
528     ucs4->ch[1] = 0x0;
529     ucs4->ch[2] = 0x0;
530     ucs4->ch[3] = 0xa0;
531   } else if (0x21 <= tis620_code && tis620_code <= 0x7f) {
532     ucs4->ch[0] = 0x0;
533     ucs4->ch[1] = 0x0;
534     ucs4->ch[2] = 0x0e;
535     ucs4->ch[3] = tis620_code - 0x20;
536   } else {
537     return 0;
538   }
539 
540   ucs4->size = 4;
541   ucs4->cs = ISO10646_UCS4_1;
542   ucs4->property = 0;
543 
544   return 1;
545 }
546 
ef_map_iso8859_13_r_to_ucs4(ef_char_t * ucs4,u_int16_t iso8859_code)547 int ef_map_iso8859_13_r_to_ucs4(ef_char_t *ucs4, u_int16_t iso8859_code) {
548   u_int32_t c;
549 
550   if ((c = CONV_ISO8859_13_R_TO_UCS4(iso8859_code + 0x80))) {
551     ef_int_to_bytes(ucs4->ch, 4, c);
552     ucs4->size = 4;
553     ucs4->cs = ISO10646_UCS4_1;
554     ucs4->property = 0;
555 
556     return 1;
557   }
558 
559   return 0;
560 }
561 
ef_map_iso8859_14_r_to_ucs4(ef_char_t * ucs4,u_int16_t iso8859_code)562 int ef_map_iso8859_14_r_to_ucs4(ef_char_t *ucs4, u_int16_t iso8859_code) {
563   u_int32_t c;
564 
565   if ((c = CONV_ISO8859_14_R_TO_UCS4(iso8859_code + 0x80))) {
566     ef_int_to_bytes(ucs4->ch, 4, c);
567     ucs4->size = 4;
568     ucs4->cs = ISO10646_UCS4_1;
569     ucs4->property = 0;
570 
571     return 1;
572   }
573 
574   return 0;
575 }
576 
ef_map_iso8859_15_r_to_ucs4(ef_char_t * ucs4,u_int16_t iso8859_code)577 int ef_map_iso8859_15_r_to_ucs4(ef_char_t *ucs4, u_int16_t iso8859_code) {
578   if (iso8859_code == 0x24) {
579     ucs4->ch[2] = 0x20;
580     ucs4->ch[3] = 0xac;
581   } else if (iso8859_code == 0x26) {
582     ucs4->ch[2] = 0x01;
583     ucs4->ch[3] = 0x60;
584   } else if (iso8859_code == 0x28) {
585     ucs4->ch[2] = 0x01;
586     ucs4->ch[3] = 0x61;
587   } else if (iso8859_code == 0x34) {
588     ucs4->ch[2] = 0x01;
589     ucs4->ch[3] = 0x7d;
590   } else if (iso8859_code == 0x38) {
591     ucs4->ch[2] = 0x01;
592     ucs4->ch[3] = 0x7e;
593   } else if (iso8859_code == 0x3c || iso8859_code == 0x3d) {
594     ucs4->ch[2] = 0x01;
595     ucs4->ch[3] = 0x52 + (iso8859_code - 0x3c);
596   } else if (iso8859_code == 0xbe) {
597     ucs4->ch[2] = 0x01;
598     ucs4->ch[3] = 0x78;
599   } else {
600     return convert_iso8859_r_common_to_ucs4(ucs4, iso8859_code);
601   }
602 
603   ucs4->ch[0] = 0x0;
604   ucs4->ch[1] = 0x0;
605 
606   ucs4->size = 4;
607   ucs4->cs = ISO10646_UCS4_1;
608   ucs4->property = 0;
609 
610   return 1;
611 }
612 
ef_map_iso8859_16_r_to_ucs4(ef_char_t * ucs4,u_int16_t iso8859_code)613 int ef_map_iso8859_16_r_to_ucs4(ef_char_t *ucs4, u_int16_t iso8859_code) {
614   u_int32_t c;
615 
616   if ((c = CONV_ISO8859_16_R_TO_UCS4(iso8859_code + 0x80))) {
617     ef_int_to_bytes(ucs4->ch, 4, c);
618     ucs4->size = 4;
619     ucs4->cs = ISO10646_UCS4_1;
620     ucs4->property = 0;
621 
622     return 1;
623   }
624 
625   return 0;
626 }
627 
ef_map_tcvn5712_3_1993_to_ucs4(ef_char_t * ucs4,u_int16_t tcvn_code)628 int ef_map_tcvn5712_3_1993_to_ucs4(ef_char_t *ucs4, u_int16_t tcvn_code) {
629   if (tcvn_code < 0x20) {
630     return 0;
631   }
632 
633   return ef_map_tcvn5712_1_1993_to_ucs4(ucs4, tcvn_code + 0x80);
634 }
635