1 /* -*- c-basic-offset:2; tab-width:2; indent-tabs-mode:nil -*- */
2
3 #include "../src/ef_ucs4_jisx0208.h"
4
5 #include "../src/ef_jis_property.h"
6 #include "table/ef_jisx0208_1983_to_ucs4.table"
7 #include "table/ef_jisx0208_nec_ext_to_ucs4.table"
8 #include "table/ef_jisx0208_necibm_ext_to_ucs4.table"
9 #include "table/ef_sjis_ibm_ext_to_ucs4.table"
10
11 #include "table/ef_ucs4_to_jisx0208_1983.table"
12
13 /* --- global functions --- */
14
ef_map_jisx0208_1983_to_ucs4(ef_char_t * ucs4,u_int16_t jis)15 int ef_map_jisx0208_1983_to_ucs4(ef_char_t *ucs4, u_int16_t jis) {
16 u_int32_t c;
17
18 if ((c = CONV_JISX0208_1983_TO_UCS4(jis))) {
19 ef_int_to_bytes(ucs4->ch, 4, c);
20 ucs4->size = 4;
21 ucs4->cs = ISO10646_UCS4_1;
22 ucs4->property = 0;
23
24 return 1;
25 }
26
27 return 0;
28 }
29
ef_map_jisx0208_nec_ext_to_ucs4(ef_char_t * ucs4,u_int16_t nec_ext)30 int ef_map_jisx0208_nec_ext_to_ucs4(ef_char_t *ucs4, u_int16_t nec_ext) {
31 u_int32_t c;
32
33 if ((c = CONV_JISX0208_NEC_EXT_TO_UCS4(nec_ext))) {
34 ef_int_to_bytes(ucs4->ch, 4, c);
35 ucs4->size = 4;
36 ucs4->cs = ISO10646_UCS4_1;
37 ucs4->property = 0;
38
39 return 1;
40 }
41
42 return 0;
43 }
44
ef_map_jisx0208_necibm_ext_to_ucs4(ef_char_t * ucs4,u_int16_t necibm_ext)45 int ef_map_jisx0208_necibm_ext_to_ucs4(ef_char_t *ucs4, u_int16_t necibm_ext) {
46 u_int32_t c;
47
48 if ((c = CONV_JISX0208_NECIBM_EXT_TO_UCS4(necibm_ext))) {
49 ef_int_to_bytes(ucs4->ch, 4, c);
50 ucs4->size = 4;
51 ucs4->cs = ISO10646_UCS4_1;
52 ucs4->property = 0;
53
54 return 1;
55 }
56
57 return 0;
58 }
59
ef_map_sjis_ibm_ext_to_ucs4(ef_char_t * ucs4,u_int16_t ibm_ext)60 int ef_map_sjis_ibm_ext_to_ucs4(ef_char_t *ucs4, u_int16_t ibm_ext) {
61 u_int32_t c;
62
63 if ((c = CONV_SJIS_IBM_EXT_TO_UCS4(ibm_ext))) {
64 ef_int_to_bytes(ucs4->ch, 4, c);
65 ucs4->size = 4;
66 ucs4->cs = ISO10646_UCS4_1;
67 ucs4->property = 0;
68
69 return 1;
70 }
71
72 return 0;
73 }
74
ef_map_ucs4_to_jisx0208_1983(ef_char_t * non_ucs,u_int32_t ucs4_code)75 int ef_map_ucs4_to_jisx0208_1983(ef_char_t *non_ucs, u_int32_t ucs4_code) {
76 u_int16_t c;
77
78 if ((c = CONV_UCS4_TO_JISX0208_1983(ucs4_code))) {
79 ef_int_to_bytes(non_ucs->ch, 2, c);
80 non_ucs->size = 2;
81 non_ucs->cs = JISX0208_1983;
82 non_ucs->property = ef_get_jisx0208_1983_property(non_ucs->ch);
83
84 return 1;
85 }
86
87 return 0;
88 }
89
ef_map_ucs4_to_jisx0208_nec_ext(ef_char_t * non_ucs,u_int32_t ucs4_code)90 int ef_map_ucs4_to_jisx0208_nec_ext(ef_char_t *non_ucs, u_int32_t ucs4_code) {
91 u_int16_t offset;
92
93 for (offset = 0; offset <= jisx0208_nec_ext_to_ucs4_end - jisx0208_nec_ext_to_ucs4_beg;
94 offset++) {
95 if (jisx0208_nec_ext_to_ucs4_table[offset] == (u_int16_t)ucs4_code) {
96 ef_int_to_bytes(non_ucs->ch, 2, offset + jisx0208_nec_ext_to_ucs4_beg);
97 non_ucs->cs = JISC6226_1978_NEC_EXT;
98 non_ucs->size = 2;
99 non_ucs->property = 0;
100
101 return 1;
102 }
103 }
104
105 return 0;
106 }
107
ef_map_ucs4_to_jisx0208_necibm_ext(ef_char_t * non_ucs,u_int32_t ucs4_code)108 int ef_map_ucs4_to_jisx0208_necibm_ext(ef_char_t *non_ucs, u_int32_t ucs4_code) {
109 u_int16_t offset;
110
111 for (offset = 0; offset <= jisx0208_necibm_ext_to_ucs4_end - jisx0208_necibm_ext_to_ucs4_beg;
112 offset++) {
113 if (jisx0208_necibm_ext_to_ucs4_table[offset] == (u_int16_t)ucs4_code) {
114 ef_int_to_bytes(non_ucs->ch, 2, offset + jisx0208_necibm_ext_to_ucs4_beg);
115 non_ucs->cs = JISC6226_1978_NECIBM_EXT;
116 non_ucs->size = 2;
117 non_ucs->property = 0;
118
119 return 1;
120 }
121 }
122
123 return 0;
124 }
125
ef_map_ucs4_to_sjis_ibm_ext(ef_char_t * non_ucs,u_int32_t ucs4_code)126 int ef_map_ucs4_to_sjis_ibm_ext(ef_char_t *non_ucs, u_int32_t ucs4_code) {
127 u_int16_t offset;
128
129 for (offset = 0; offset <= sjis_ibm_ext_to_ucs4_end - sjis_ibm_ext_to_ucs4_beg; offset++) {
130 if (sjis_ibm_ext_to_ucs4_table[offset] == (u_int16_t)ucs4_code) {
131 ef_int_to_bytes(non_ucs->ch, 2, offset + sjis_ibm_ext_to_ucs4_beg);
132 non_ucs->cs = SJIS_IBM_EXT;
133 non_ucs->size = 2;
134 non_ucs->property = 0;
135
136 return 1;
137 }
138 }
139
140 return 0;
141 }
142