This source file includes following definitions.
- euctw_mbc_enc_len
- euctw_mbc_to_code
- euctw_code_to_mbc
- euctw_mbc_case_fold
- euctw_is_code_ctype
- euctw_left_adjust_char_head
- euctw_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_EUCTW[] = {
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, 4, 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 euctw_mbc_enc_len(const UChar* p)
53 {
54 return EncLen_EUCTW[*p];
55 }
56
57 static OnigCodePoint
58 euctw_mbc_to_code(const UChar* p, const UChar* end)
59 {
60 return onigenc_mbn_mbc_to_code(ONIG_ENCODING_EUC_TW, p, end);
61 }
62
63 static int
64 euctw_code_to_mbc(OnigCodePoint code, UChar *buf)
65 {
66 return onigenc_mb4_code_to_mbc(ONIG_ENCODING_EUC_TW, code, buf);
67 }
68
69 static int
70 euctw_mbc_case_fold(OnigCaseFoldType flag, const UChar** pp, const UChar* end,
71 UChar* lower)
72 {
73 return onigenc_mbn_mbc_case_fold(ONIG_ENCODING_EUC_TW, flag,
74 pp, end, lower);
75 }
76
77 static int
78 euctw_is_code_ctype(OnigCodePoint code, unsigned int ctype)
79 {
80 return onigenc_mb4_is_code_ctype(ONIG_ENCODING_EUC_TW, code, ctype);
81 }
82
83 #define euctw_islead(c) ((UChar )((c) - 0xa1) > 0xfe - 0xa1)
84
85 static UChar*
86 euctw_left_adjust_char_head(const UChar* start, const UChar* s)
87 {
88
89
90
91 const UChar *p;
92 int len;
93
94 if (s <= start) return (UChar* )s;
95 p = s;
96
97 while (!euctw_islead(*p) && p > start) p--;
98 len = enclen(ONIG_ENCODING_EUC_TW, p);
99 if (p + len > s) return (UChar* )p;
100 p += len;
101 return (UChar* )(p + ((s - p) & ~1));
102 }
103
104 static int
105 euctw_is_allowed_reverse_match(const UChar* s, const UChar* end ARG_UNUSED)
106 {
107 const UChar c = *s;
108 if (c <= 0x7e) return TRUE;
109 else return FALSE;
110 }
111
112 OnigEncodingType OnigEncodingEUC_TW = {
113 euctw_mbc_enc_len,
114 "EUC-TW",
115 4,
116 1,
117 onigenc_is_mbc_newline_0x0a,
118 euctw_mbc_to_code,
119 onigenc_mb4_code_to_mbclen,
120 euctw_code_to_mbc,
121 euctw_mbc_case_fold,
122 onigenc_ascii_apply_all_case_fold,
123 onigenc_ascii_get_case_fold_codes_by_str,
124 onigenc_minimum_property_name_to_ctype,
125 euctw_is_code_ctype,
126 onigenc_not_support_get_ctype_code_range,
127 euctw_left_adjust_char_head,
128 euctw_is_allowed_reverse_match
129 };