This source file includes following definitions.
- big5_mbc_enc_len
- big5_mbc_to_code
- big5_code_to_mbc
- big5_mbc_case_fold
- big5_is_mbc_ambiguous
- big5_is_code_ctype
- big5_left_adjust_char_head
- big5_is_allowed_reverse_match
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 #include "regenc.h"
31
32 static const int EncLen_BIG5[] = {
33 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
34 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
35 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
36 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
37 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
38 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
39 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
40 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
41 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
42 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
43 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
44 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
45 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
46 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
47 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
48 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1
49 };
50
51 static int
52 big5_mbc_enc_len(const UChar* p)
53 {
54 return EncLen_BIG5[*p];
55 }
56
57 static OnigCodePoint
58 big5_mbc_to_code(const UChar* p, const UChar* end)
59 {
60 return onigenc_mbn_mbc_to_code(ONIG_ENCODING_BIG5, p, end);
61 }
62
63 static int
64 big5_code_to_mbc(OnigCodePoint code, UChar *buf)
65 {
66 return onigenc_mb2_code_to_mbc(ONIG_ENCODING_BIG5, code, buf);
67 }
68
69 static int
70 big5_mbc_case_fold(OnigCaseFoldType flag, const UChar** pp, const UChar* end,
71 UChar* lower)
72 {
73 return onigenc_mbn_mbc_case_fold(ONIG_ENCODING_BIG5, flag,
74 pp, end, lower);
75 }
76
77 #if 0
78 static int
79 big5_is_mbc_ambiguous(OnigCaseFoldType flag,
80 const UChar** pp, const UChar* end)
81 {
82 return onigenc_mbn_is_mbc_ambiguous(ONIG_ENCODING_BIG5, flag, pp, end);
83 }
84 #endif
85
86 static int
87 big5_is_code_ctype(OnigCodePoint code, unsigned int ctype)
88 {
89 return onigenc_mb2_is_code_ctype(ONIG_ENCODING_BIG5, code, ctype);
90 }
91
92 static const char BIG5_CAN_BE_TRAIL_TABLE[256] = {
93 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
94 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
95 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
96 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
97 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
98 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
99 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
100 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
101 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
102 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
103 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
104 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
105 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
106 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
107 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
108 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0
109 };
110
111 #define BIG5_ISMB_FIRST(byte) (EncLen_BIG5[byte] > 1)
112 #define BIG5_ISMB_TRAIL(byte) BIG5_CAN_BE_TRAIL_TABLE[(byte)]
113
114 static UChar*
115 big5_left_adjust_char_head(const UChar* start, const UChar* s)
116 {
117 const UChar *p;
118 int len;
119
120 if (s <= start) return (UChar* )s;
121 p = s;
122
123 if (BIG5_ISMB_TRAIL(*p)) {
124 while (p > start) {
125 if (! BIG5_ISMB_FIRST(*--p)) {
126 p++;
127 break;
128 }
129 }
130 }
131 len = enclen(ONIG_ENCODING_BIG5, p);
132 if (p + len > s) return (UChar* )p;
133 p += len;
134 return (UChar* )(p + ((s - p) & ~1));
135 }
136
137 static int
138 big5_is_allowed_reverse_match(const UChar* s, const UChar* end ARG_UNUSED)
139 {
140 const UChar c = *s;
141
142 return (BIG5_ISMB_TRAIL(c) ? FALSE : TRUE);
143 }
144
145 OnigEncodingType OnigEncodingBIG5 = {
146 big5_mbc_enc_len,
147 "Big5",
148 2,
149 1,
150 onigenc_is_mbc_newline_0x0a,
151 big5_mbc_to_code,
152 onigenc_mb2_code_to_mbclen,
153 big5_code_to_mbc,
154 big5_mbc_case_fold,
155 onigenc_ascii_apply_all_case_fold,
156 onigenc_ascii_get_case_fold_codes_by_str,
157 onigenc_minimum_property_name_to_ctype,
158 big5_is_code_ctype,
159 onigenc_not_support_get_ctype_code_range,
160 big5_left_adjust_char_head,
161 big5_is_allowed_reverse_match
162 };