1 /* -*- c-basic-offset:2; tab-width:2; indent-tabs-mode:nil -*- */
2 
3 #include "../src/ef_ucs4_jisx0213.h"
4 
5 #include "../src/ef_jis_property.h"
6 #include "table/ef_jisx0213_2000_1_to_ucs4.table"
7 #include "table/ef_jisx0213_2000_2_to_ucs4.table"
8 
9 #include "table/ef_ucs4_to_jisx0213_2000_1.table"
10 #include "table/ef_ucs4_to_jisx0213_2000_2.table"
11 
12 /* --- global functions --- */
13 
ef_map_jisx0213_2000_1_to_ucs4(ef_char_t * ucs4,u_int16_t jis)14 int ef_map_jisx0213_2000_1_to_ucs4(ef_char_t *ucs4, u_int16_t jis) {
15   u_int32_t c;
16 
17   if ((c = CONV_JISX0213_2000_1_TO_UCS4(jis))) {
18     ef_int_to_bytes(ucs4->ch, 4, c);
19     ucs4->size = 4;
20     ucs4->cs = ISO10646_UCS4_1;
21     ucs4->property = 0;
22 
23     return 1;
24   }
25 
26   return 0;
27 }
28 
ef_map_jisx0213_2000_2_to_ucs4(ef_char_t * ucs4,u_int16_t jis)29 int ef_map_jisx0213_2000_2_to_ucs4(ef_char_t *ucs4, u_int16_t jis) {
30   u_int32_t c;
31 
32   if ((c = CONV_JISX0213_2000_2_TO_UCS4(jis))) {
33     ef_int_to_bytes(ucs4->ch, 4, c);
34     ucs4->size = 4;
35     ucs4->cs = ISO10646_UCS4_1;
36     ucs4->property = 0;
37 
38     return 1;
39   }
40 
41   return 0;
42 }
43 
ef_map_ucs4_to_jisx0213_2000_1(ef_char_t * jis,u_int32_t ucs4_code)44 int ef_map_ucs4_to_jisx0213_2000_1(ef_char_t *jis, u_int32_t ucs4_code) {
45   u_int16_t c;
46 
47   if ((c = CONV_UCS4_TO_JISX0213_2000_1(ucs4_code))) {
48     ef_int_to_bytes(jis->ch, 2, c);
49     jis->size = 2;
50     jis->cs = JISX0213_2000_1;
51     jis->property = ef_get_jisx0213_2000_1_property(jis->ch);
52 
53     return 1;
54   }
55 
56   return 0;
57 }
58 
ef_map_ucs4_to_jisx0213_2000_2(ef_char_t * jis,u_int32_t ucs4_code)59 int ef_map_ucs4_to_jisx0213_2000_2(ef_char_t *jis, u_int32_t ucs4_code) {
60   u_int16_t c;
61 
62   if ((c = CONV_UCS4_TO_JISX0213_2000_2(ucs4_code))) {
63     ef_int_to_bytes(jis->ch, 2, c);
64     jis->size = 2;
65     jis->cs = JISX0213_2000_2;
66     jis->property = 0;
67 
68     return 1;
69   }
70 
71   return 0;
72 }
73