1 /* -*- c-basic-offset:2; tab-width:2; indent-tabs-mode:nil -*- */
2
3 #include "../src/ef_ucs4_big5.h"
4
5 #include "table/ef_big5_to_ucs4.table"
6 #include "table/ef_hkscs_to_ucs4.table"
7
8 #include "table/ef_ucs4_to_big5.table"
9 #include "table/ef_ucs4_to_hkscs.table"
10
11 /* --- global functions --- */
12
ef_map_big5_to_ucs4(ef_char_t * ucs4,u_int16_t big5)13 int ef_map_big5_to_ucs4(ef_char_t *ucs4, u_int16_t big5) {
14 u_int32_t c;
15
16 if ((c = CONV_BIG5_TO_UCS4(big5))) {
17 ef_int_to_bytes(ucs4->ch, 4, c);
18 ucs4->size = 4;
19 ucs4->cs = ISO10646_UCS4_1;
20 ucs4->property = 0;
21
22 return 1;
23 }
24
25 return 0;
26 }
27
ef_map_hkscs_to_ucs4(ef_char_t * ucs4,u_int16_t hkscs)28 int ef_map_hkscs_to_ucs4(ef_char_t *ucs4, u_int16_t hkscs) {
29 u_int32_t c;
30
31 if ((c = CONV_HKSCS_TO_UCS4(hkscs))) {
32 ef_int_to_bytes(ucs4->ch, 4, c);
33 ucs4->size = 4;
34 ucs4->cs = ISO10646_UCS4_1;
35 ucs4->property = 0;
36
37 return 1;
38 }
39
40 return 0;
41 }
42
ef_map_ucs4_to_big5(ef_char_t * big5,u_int32_t ucs4_code)43 int ef_map_ucs4_to_big5(ef_char_t *big5, u_int32_t ucs4_code) {
44 u_int16_t c;
45
46 if ((c = CONV_UCS4_TO_BIG5(ucs4_code))) {
47 ef_int_to_bytes(big5->ch, 2, c);
48 big5->size = 2;
49 big5->cs = BIG5;
50 big5->property = 0;
51
52 return 1;
53 }
54
55 return 0;
56 }
57
ef_map_ucs4_to_hkscs(ef_char_t * hkscs,u_int32_t ucs4_code)58 int ef_map_ucs4_to_hkscs(ef_char_t *hkscs, u_int32_t ucs4_code) {
59 u_int16_t c;
60
61 if ((c = CONV_UCS4_TO_HKSCS(ucs4_code))) {
62 ef_int_to_bytes(hkscs->ch, 2, c);
63 hkscs->size = 2;
64 hkscs->cs = HKSCS;
65 hkscs->property = 0;
66
67 return 1;
68 }
69
70 return 0;
71 }
72