This source file includes following definitions.
- uc_general_category_byname
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 #include <config.h>
27
28
29 #include "unictype.h"
30
31 #include <stdlib.h>
32 #include <string.h>
33
34
35
36
37 enum
38 {
39 UC_CATEGORY_INDEX_L,
40 UC_CATEGORY_INDEX_LC,
41 UC_CATEGORY_INDEX_Lu,
42 UC_CATEGORY_INDEX_Ll,
43 UC_CATEGORY_INDEX_Lt,
44 UC_CATEGORY_INDEX_Lm,
45 UC_CATEGORY_INDEX_Lo,
46 UC_CATEGORY_INDEX_M,
47 UC_CATEGORY_INDEX_Mn,
48 UC_CATEGORY_INDEX_Mc,
49 UC_CATEGORY_INDEX_Me,
50 UC_CATEGORY_INDEX_N,
51 UC_CATEGORY_INDEX_Nd,
52 UC_CATEGORY_INDEX_Nl,
53 UC_CATEGORY_INDEX_No,
54 UC_CATEGORY_INDEX_P,
55 UC_CATEGORY_INDEX_Pc,
56 UC_CATEGORY_INDEX_Pd,
57 UC_CATEGORY_INDEX_Ps,
58 UC_CATEGORY_INDEX_Pe,
59 UC_CATEGORY_INDEX_Pi,
60 UC_CATEGORY_INDEX_Pf,
61 UC_CATEGORY_INDEX_Po,
62 UC_CATEGORY_INDEX_S,
63 UC_CATEGORY_INDEX_Sm,
64 UC_CATEGORY_INDEX_Sc,
65 UC_CATEGORY_INDEX_Sk,
66 UC_CATEGORY_INDEX_So,
67 UC_CATEGORY_INDEX_Z,
68 UC_CATEGORY_INDEX_Zs,
69 UC_CATEGORY_INDEX_Zl,
70 UC_CATEGORY_INDEX_Zp,
71 UC_CATEGORY_INDEX_C,
72 UC_CATEGORY_INDEX_Cc,
73 UC_CATEGORY_INDEX_Cf,
74 UC_CATEGORY_INDEX_Cs,
75 UC_CATEGORY_INDEX_Co,
76 UC_CATEGORY_INDEX_Cn
77 };
78
79 #include "unictype/categ_byname.h"
80
81 uc_general_category_t
82 uc_general_category_byname (const char *category_name)
83 {
84 size_t len;
85
86 len = strlen (category_name);
87 if (len <= MAX_WORD_LENGTH)
88 {
89 char buf[MAX_WORD_LENGTH + 1];
90 const struct named_category *found;
91
92
93 {
94 const char *p = category_name;
95 char *q = buf;
96
97 for (;; p++, q++)
98 {
99 char c = *p;
100
101 if (c == '_' || c == '-')
102 c = ' ';
103 *q = c;
104 if (c == '\0')
105 break;
106 }
107 }
108
109
110
111 found = uc_general_category_lookup (buf, len);
112 if (found != NULL)
113
114
115 switch (found->category_index)
116 {
117 case UC_CATEGORY_INDEX_L:
118 return UC_CATEGORY_L;
119 case UC_CATEGORY_INDEX_LC:
120 return UC_CATEGORY_LC;
121 case UC_CATEGORY_INDEX_Lu:
122 return UC_CATEGORY_Lu;
123 case UC_CATEGORY_INDEX_Ll:
124 return UC_CATEGORY_Ll;
125 case UC_CATEGORY_INDEX_Lt:
126 return UC_CATEGORY_Lt;
127 case UC_CATEGORY_INDEX_Lm:
128 return UC_CATEGORY_Lm;
129 case UC_CATEGORY_INDEX_Lo:
130 return UC_CATEGORY_Lo;
131 case UC_CATEGORY_INDEX_M:
132 return UC_CATEGORY_M;
133 case UC_CATEGORY_INDEX_Mn:
134 return UC_CATEGORY_Mn;
135 case UC_CATEGORY_INDEX_Mc:
136 return UC_CATEGORY_Mc;
137 case UC_CATEGORY_INDEX_Me:
138 return UC_CATEGORY_Me;
139 case UC_CATEGORY_INDEX_N:
140 return UC_CATEGORY_N;
141 case UC_CATEGORY_INDEX_Nd:
142 return UC_CATEGORY_Nd;
143 case UC_CATEGORY_INDEX_Nl:
144 return UC_CATEGORY_Nl;
145 case UC_CATEGORY_INDEX_No:
146 return UC_CATEGORY_No;
147 case UC_CATEGORY_INDEX_P:
148 return UC_CATEGORY_P;
149 case UC_CATEGORY_INDEX_Pc:
150 return UC_CATEGORY_Pc;
151 case UC_CATEGORY_INDEX_Pd:
152 return UC_CATEGORY_Pd;
153 case UC_CATEGORY_INDEX_Ps:
154 return UC_CATEGORY_Ps;
155 case UC_CATEGORY_INDEX_Pe:
156 return UC_CATEGORY_Pe;
157 case UC_CATEGORY_INDEX_Pi:
158 return UC_CATEGORY_Pi;
159 case UC_CATEGORY_INDEX_Pf:
160 return UC_CATEGORY_Pf;
161 case UC_CATEGORY_INDEX_Po:
162 return UC_CATEGORY_Po;
163 case UC_CATEGORY_INDEX_S:
164 return UC_CATEGORY_S;
165 case UC_CATEGORY_INDEX_Sm:
166 return UC_CATEGORY_Sm;
167 case UC_CATEGORY_INDEX_Sc:
168 return UC_CATEGORY_Sc;
169 case UC_CATEGORY_INDEX_Sk:
170 return UC_CATEGORY_Sk;
171 case UC_CATEGORY_INDEX_So:
172 return UC_CATEGORY_So;
173 case UC_CATEGORY_INDEX_Z:
174 return UC_CATEGORY_Z;
175 case UC_CATEGORY_INDEX_Zs:
176 return UC_CATEGORY_Zs;
177 case UC_CATEGORY_INDEX_Zl:
178 return UC_CATEGORY_Zl;
179 case UC_CATEGORY_INDEX_Zp:
180 return UC_CATEGORY_Zp;
181 case UC_CATEGORY_INDEX_C:
182 return UC_CATEGORY_C;
183 case UC_CATEGORY_INDEX_Cc:
184 return UC_CATEGORY_Cc;
185 case UC_CATEGORY_INDEX_Cf:
186 return UC_CATEGORY_Cf;
187 case UC_CATEGORY_INDEX_Cs:
188 return UC_CATEGORY_Cs;
189 case UC_CATEGORY_INDEX_Co:
190 return UC_CATEGORY_Co;
191 case UC_CATEGORY_INDEX_Cn:
192 return UC_CATEGORY_Cn;
193 default:
194 abort ();
195 }
196 }
197
198 return _UC_CATEGORY_NONE;
199 }