1 /* -*- c-basic-offset:2; tab-width:2; indent-tabs-mode:nil -*- */
2
3 #include "ef_ucs4_cp125x.h"
4
5 #include "ef_tblfunc_loader.h"
6 #include "ef_ucs4_iso8859.h"
7
8 /* --- static variables --- */
9
10 static struct {
11 u_int8_t cp874;
12 u_int8_t ucs4; /* 0x20NN */
13
14 } cp874_table[] = {
15 {0x80, 0xac},
16 {0x85, 0x26},
17 {0x91, 0x18},
18 {0x92, 0x19},
19 {0x93, 0x1c},
20 {0x94, 0x1d},
21 {0x95, 0x22},
22 {0x96, 0x13},
23 {0x97, 0x14},
24 };
25
26 /* --- global functions --- */
27
28 #ifdef NO_DYNAMIC_LOAD_TABLE
29
30 #include "../module/ef_ucs4_cp125x.c"
31
32 #else
33
34 ef_map_func(8bits, ef_map_cp1250_to_ucs4, 16)
35 ef_map_func(8bits, ef_map_cp1251_to_ucs4, 16)
36 ef_map_func(8bits, ef_map_cp1252_to_ucs4, 16)
37 ef_map_func(8bits, ef_map_cp1253_to_ucs4, 16)
38 ef_map_func(8bits, ef_map_cp1254_to_ucs4, 16)
39 ef_map_func(8bits, ef_map_cp1255_to_ucs4, 16)
40 ef_map_func(8bits, ef_map_cp1256_to_ucs4, 16)
41 ef_map_func(8bits, ef_map_cp1257_to_ucs4, 16)
42 ef_map_func(8bits, ef_map_cp1258_to_ucs4, 16)
43
44 ef_map_func(8bits, ef_map_ucs4_to_cp1250, 32)
45 ef_map_func(8bits, ef_map_ucs4_to_cp1251, 32)
46 ef_map_func(8bits, ef_map_ucs4_to_cp1252, 32)
47 ef_map_func(8bits, ef_map_ucs4_to_cp1253, 32)
48 ef_map_func(8bits, ef_map_ucs4_to_cp1254, 32)
49 ef_map_func(8bits, ef_map_ucs4_to_cp1255, 32)
50 ef_map_func(8bits, ef_map_ucs4_to_cp1256, 32)
51 ef_map_func(8bits, ef_map_ucs4_to_cp1257, 32)
52 ef_map_func(8bits, ef_map_ucs4_to_cp1258, 32)
53
54 #endif
55
ef_map_cp874_to_ucs4(ef_char_t * ucs4,u_int16_t cp874_code)56 int ef_map_cp874_to_ucs4(ef_char_t *ucs4, u_int16_t cp874_code) {
57 size_t count;
58
59 if (ef_map_tis620_2533_to_ucs4(ucs4, cp874_code & 0x7f)) {
60 return 1;
61 }
62
63 for (count = 0; count < sizeof(cp874_table) / sizeof(cp874_table[0]); count++) {
64 if (cp874_table[count].cp874 == cp874_code) {
65 ucs4->ch[0] = 0x0;
66 ucs4->ch[1] = 0x0;
67 ucs4->ch[2] = 0x20;
68 ucs4->ch[3] = cp874_table[count].ucs4;
69 ucs4->size = 4;
70 ucs4->cs = ISO10646_UCS4_1;
71 ucs4->property = 0;
72
73 return 1;
74 }
75 }
76
77 return 0;
78 }
79
ef_map_ucs4_to_cp874(ef_char_t * non_ucs,u_int32_t ucs4_code)80 int ef_map_ucs4_to_cp874(ef_char_t *non_ucs, u_int32_t ucs4_code) {
81 size_t count;
82
83 if (ef_map_ucs4_to_tis620_2533(non_ucs, ucs4_code)) {
84 non_ucs->ch[0] |= 0x80;
85 non_ucs->cs = CP874;
86
87 return 1;
88 }
89
90 for (count = 0; count < sizeof(cp874_table) / sizeof(cp874_table[0]); count++) {
91 if (((u_int32_t)cp874_table[count].ucs4) + 0x2000 == ucs4_code) {
92 non_ucs->ch[0] = cp874_table[count].cp874;
93 non_ucs->size = 1;
94 non_ucs->cs = CP874;
95 non_ucs->property = 0;
96
97 return 1;
98 }
99 }
100
101 return 0;
102 }
103