OLD | NEW |
1 /* | 1 /* |
2 ******************************************************************************* | 2 ******************************************************************************* |
3 * Copyright (C) 2013, International Business Machines | 3 * Copyright (C) 2013-2014, International Business Machines |
4 * Corporation and others. All Rights Reserved. | 4 * Corporation and others. All Rights Reserved. |
5 ******************************************************************************* | 5 ******************************************************************************* |
6 * file name: uscript_props.cpp | 6 * file name: uscript_props.cpp |
7 * encoding: US-ASCII | 7 * encoding: US-ASCII |
8 * tab size: 8 (not used) | 8 * tab size: 8 (not used) |
9 * indentation:4 | 9 * indentation:4 |
10 * | 10 * |
11 * created on: 2013feb16 | 11 * created on: 2013feb16 |
12 * created by: Markus W. Scherer | 12 * created by: Markus W. Scherer |
13 */ | 13 */ |
14 | 14 |
15 #include "unicode/utypes.h" | 15 #include "unicode/utypes.h" |
16 #include "unicode/unistr.h" | 16 #include "unicode/unistr.h" |
17 #include "unicode/uscript.h" | 17 #include "unicode/uscript.h" |
18 #include "unicode/utf16.h" | 18 #include "unicode/utf16.h" |
19 #include "ustr_imp.h" | 19 #include "ustr_imp.h" |
20 | 20 #include "cmemory.h" |
21 #define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0])) | |
22 | 21 |
23 namespace { | 22 namespace { |
24 | 23 |
25 // Script metadata (script properties). | 24 // Script metadata (script properties). |
26 // See http://unicode.org/cldr/trac/browser/trunk/common/properties/scriptMetada
ta.txt | 25 // See http://unicode.org/cldr/trac/browser/trunk/common/properties/scriptMetada
ta.txt |
27 | 26 |
28 // 0 = NOT_ENCODED, no sample character, default false script properties. | 27 // 0 = NOT_ENCODED, no sample character, default false script properties. |
29 // Bits 20.. 0: sample character | 28 // Bits 20.. 0: sample character |
30 | 29 |
31 // Bits 23..21: usage | 30 // Bits 23..21: usage |
32 const int32_t UNKNOWN = 1 << 21; | 31 const int32_t UNKNOWN = 1 << 21; |
33 const int32_t EXCLUSION = 2 << 21; | 32 const int32_t EXCLUSION = 2 << 21; |
34 const int32_t LIMITED_USE = 3 << 21; | 33 const int32_t LIMITED_USE = 3 << 21; |
35 const int32_t ASPIRATIONAL = 4 << 21; | 34 const int32_t ASPIRATIONAL = 4 << 21; |
36 const int32_t RECOMMENDED = 5 << 21; | 35 const int32_t RECOMMENDED = 5 << 21; |
37 | 36 |
38 // Bits 31..24: Single-bit flags | 37 // Bits 31..24: Single-bit flags |
39 const int32_t RTL = 1 << 24; | 38 const int32_t RTL = 1 << 24; |
40 const int32_t LB_LETTERS = 1 << 25; | 39 const int32_t LB_LETTERS = 1 << 25; |
41 const int32_t CASED = 1 << 26; | 40 const int32_t CASED = 1 << 26; |
42 | 41 |
43 const int32_t SCRIPT_PROPS[] = { | 42 const int32_t SCRIPT_PROPS[] = { |
44 // Begin copy-paste output from | 43 // Begin copy-paste output from |
45 // tools/trunk/unicode/py/parsescriptmetadata.py | 44 // tools/trunk/unicode/py/parsescriptmetadata.py |
46 0x0040 | UNKNOWN, // Zyyy | 45 0x0040 | RECOMMENDED, // Zyyy |
47 0x0308 | UNKNOWN, // Zinh | 46 0x0308 | UNKNOWN, // Zinh |
48 0x0628 | RECOMMENDED | RTL, // Arab | 47 0x0628 | RECOMMENDED | RTL, // Arab |
49 0x0531 | RECOMMENDED | CASED, // Armn | 48 0x0531 | RECOMMENDED | CASED, // Armn |
50 0x0995 | RECOMMENDED, // Beng | 49 0x0995 | RECOMMENDED, // Beng |
51 0x3105 | RECOMMENDED | LB_LETTERS, // Bopo | 50 0x3105 | RECOMMENDED | LB_LETTERS, // Bopo |
52 0x13C4 | LIMITED_USE, // Cher | 51 0x13C4 | LIMITED_USE, // Cher |
53 0x03E2 | EXCLUSION | CASED, // Copt | 52 0x03E2 | EXCLUSION | CASED, // Copt |
54 0x042F | RECOMMENDED | CASED, // Cyrl | 53 0x042F | RECOMMENDED | CASED, // Cyrl |
55 0x10414 | EXCLUSION | CASED, // Dsrt | 54 0x10414 | EXCLUSION | CASED, // Dsrt |
56 0x0905 | RECOMMENDED, // Deva | 55 0x0905 | RECOMMENDED, // Deva |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 0x1950 | LIMITED_USE | LB_LETTERS, // Tale | 97 0x1950 | LIMITED_USE | LB_LETTERS, // Tale |
99 0x10380 | EXCLUSION, // Ugar | 98 0x10380 | EXCLUSION, // Ugar |
100 0, | 99 0, |
101 0x1A00 | EXCLUSION, // Bugi | 100 0x1A00 | EXCLUSION, // Bugi |
102 0x2C00 | EXCLUSION | CASED, // Glag | 101 0x2C00 | EXCLUSION | CASED, // Glag |
103 0x10A00 | EXCLUSION | RTL, // Khar | 102 0x10A00 | EXCLUSION | RTL, // Khar |
104 0xA800 | LIMITED_USE, // Sylo | 103 0xA800 | LIMITED_USE, // Sylo |
105 0x1980 | LIMITED_USE | LB_LETTERS, // Talu | 104 0x1980 | LIMITED_USE | LB_LETTERS, // Talu |
106 0x2D30 | ASPIRATIONAL, // Tfng | 105 0x2D30 | ASPIRATIONAL, // Tfng |
107 0x103A0 | EXCLUSION, // Xpeo | 106 0x103A0 | EXCLUSION, // Xpeo |
108 0x1B05 | LIMITED_USE | LB_LETTERS, // Bali | 107 0x1B05 | LIMITED_USE, // Bali |
109 0x1BC0 | LIMITED_USE, // Batk | 108 0x1BC0 | LIMITED_USE, // Batk |
110 0, | 109 0, |
111 0x11005 | EXCLUSION, // Brah | 110 0x11005 | EXCLUSION, // Brah |
112 0xAA00 | LIMITED_USE, // Cham | 111 0xAA00 | LIMITED_USE, // Cham |
113 0, | 112 0, |
114 0, | 113 0, |
115 0, | 114 0, |
116 0, | 115 0, |
117 0x13153 | EXCLUSION, // Egyp | 116 0x13153 | EXCLUSION, // Egyp |
118 0, | 117 0, |
119 0x5B57 | RECOMMENDED | LB_LETTERS, // Hans | 118 0x5B57 | RECOMMENDED | LB_LETTERS, // Hans |
120 0x5B57 | RECOMMENDED | LB_LETTERS, // Hant | 119 0x5B57 | RECOMMENDED | LB_LETTERS, // Hant |
| 120 0x16B1C | EXCLUSION, // Hmng |
121 0, | 121 0, |
122 0, | 122 0, |
123 0, | 123 0xA984 | LIMITED_USE, // Java |
124 0xA984 | LIMITED_USE | LB_LETTERS, // Java | |
125 0xA90A | LIMITED_USE, // Kali | 124 0xA90A | LIMITED_USE, // Kali |
126 0, | 125 0, |
127 0, | 126 0, |
128 0x1C00 | LIMITED_USE, // Lepc | 127 0x1C00 | LIMITED_USE, // Lepc |
129 0, | 128 0x10647 | EXCLUSION, // Lina |
130 0x0840 | LIMITED_USE | RTL, // Mand | 129 0x0840 | LIMITED_USE | RTL, // Mand |
131 0, | 130 0, |
132 0x10980 | EXCLUSION | RTL, // Mero | 131 0x10980 | EXCLUSION | RTL, // Mero |
133 0x07CA | LIMITED_USE | RTL, // Nkoo | 132 0x07CA | LIMITED_USE | RTL, // Nkoo |
134 0x10C00 | EXCLUSION | RTL, // Orkh | 133 0x10C00 | EXCLUSION | RTL, // Orkh |
135 0, | 134 0x1036B | EXCLUSION, // Perm |
136 0xA840 | EXCLUSION, // Phag | 135 0xA840 | EXCLUSION, // Phag |
137 0x10900 | EXCLUSION | RTL, // Phnx | 136 0x10900 | EXCLUSION | RTL, // Phnx |
138 0x16F00 | ASPIRATIONAL, // Plrd | 137 0x16F00 | ASPIRATIONAL, // Plrd |
139 0, | 138 0, |
140 0, | 139 0, |
141 0, | 140 0, |
142 0, | 141 0, |
143 0, | 142 0, |
144 0, | 143 0, |
145 0xA549 | LIMITED_USE, // Vaii | 144 0xA549 | LIMITED_USE, // Vaii |
(...skipping 11 matching lines...) Expand all Loading... |
157 0xA882 | LIMITED_USE, // Saur | 156 0xA882 | LIMITED_USE, // Saur |
158 0, | 157 0, |
159 0x1B83 | LIMITED_USE, // Sund | 158 0x1B83 | LIMITED_USE, // Sund |
160 0, | 159 0, |
161 0xABC0 | LIMITED_USE, // Mtei | 160 0xABC0 | LIMITED_USE, // Mtei |
162 0x10840 | EXCLUSION | RTL, // Armi | 161 0x10840 | EXCLUSION | RTL, // Armi |
163 0x10B00 | EXCLUSION | RTL, // Avst | 162 0x10B00 | EXCLUSION | RTL, // Avst |
164 0x11103 | LIMITED_USE, // Cakm | 163 0x11103 | LIMITED_USE, // Cakm |
165 0xAC00 | RECOMMENDED, // Kore | 164 0xAC00 | RECOMMENDED, // Kore |
166 0x11083 | EXCLUSION, // Kthi | 165 0x11083 | EXCLUSION, // Kthi |
167 0, | 166 0x10AD8 | EXCLUSION | RTL, // Mani |
168 0x10B60 | EXCLUSION | RTL, // Phli | 167 0x10B60 | EXCLUSION | RTL, // Phli |
169 0, | 168 0x10B8F | EXCLUSION | RTL, // Phlp |
170 0, | 169 0, |
171 0x10B40 | EXCLUSION | RTL, // Prti | 170 0x10B40 | EXCLUSION | RTL, // Prti |
172 0x0800 | EXCLUSION | RTL, // Samr | 171 0x0800 | EXCLUSION | RTL, // Samr |
173 0xAA80 | LIMITED_USE | LB_LETTERS, // Tavt | 172 0xAA80 | LIMITED_USE | LB_LETTERS, // Tavt |
174 0, | 173 0, |
175 0, | 174 0, |
176 0xA6A0 | LIMITED_USE, // Bamu | 175 0xA6A0 | LIMITED_USE, // Bamu |
177 0xA4D0 | LIMITED_USE, // Lisu | 176 0xA4D0 | LIMITED_USE, // Lisu |
178 0, | 177 0, |
179 0x10A60 | EXCLUSION | RTL, // Sarb | 178 0x10A60 | EXCLUSION | RTL, // Sarb |
| 179 0x16AE6 | EXCLUSION, // Bass |
| 180 0x1BC20 | EXCLUSION, // Dupl |
| 181 0x10500 | EXCLUSION, // Elba |
| 182 0x11315 | EXCLUSION, // Gran |
180 0, | 183 0, |
181 0, | 184 0, |
| 185 0x1E802 | EXCLUSION | RTL, // Mend |
| 186 0x109A0 | EXCLUSION | RTL, // Merc |
| 187 0x10A95 | EXCLUSION | RTL, // Narb |
| 188 0x10896 | EXCLUSION | RTL, // Nbat |
| 189 0x10873 | EXCLUSION | RTL, // Palm |
| 190 0x112BE | EXCLUSION, // Sind |
| 191 0x118B4 | EXCLUSION | CASED, // Wara |
182 0, | 192 0, |
183 0, | 193 0, |
184 0, | 194 0x16A4F | EXCLUSION, // Mroo |
185 0, | |
186 0, | |
187 0x109A0 | EXCLUSION | RTL, // Merc | |
188 0, | |
189 0, | |
190 0, | |
191 0, | |
192 0, | |
193 0, | |
194 0, | |
195 0, | |
196 0, | 195 0, |
197 0x11183 | EXCLUSION, // Shrd | 196 0x11183 | EXCLUSION, // Shrd |
198 0x110D0 | EXCLUSION, // Sora | 197 0x110D0 | EXCLUSION, // Sora |
199 0x11680 | EXCLUSION, // Takr | 198 0x11680 | EXCLUSION, // Takr |
200 0, | 199 0, |
201 0, | 200 0, |
202 0, | 201 0, |
| 202 0x11208 | EXCLUSION, // Khoj |
| 203 0x11484 | EXCLUSION, // Tirh |
| 204 0x10537 | EXCLUSION, // Aghb |
| 205 0x11152 | EXCLUSION, // Mahj |
203 0, | 206 0, |
204 0, | 207 0, |
| 208 0x1160E | EXCLUSION, // Modi |
205 0, | 209 0, |
206 0, | 210 0x11AC0 | EXCLUSION, // Pauc |
| 211 0x1158E | EXCLUSION, // Sidd |
207 // End copy-paste from parsescriptmetadata.py | 212 // End copy-paste from parsescriptmetadata.py |
208 }; | 213 }; |
209 | 214 |
210 int32_t getScriptProps(UScriptCode script) { | 215 int32_t getScriptProps(UScriptCode script) { |
211 if (0 <= script && script < LENGTHOF(SCRIPT_PROPS)) { | 216 if (0 <= script && script < UPRV_LENGTHOF(SCRIPT_PROPS)) { |
212 return SCRIPT_PROPS[script]; | 217 return SCRIPT_PROPS[script]; |
213 } else { | 218 } else { |
214 return 0; | 219 return 0; |
215 } | 220 } |
216 } | 221 } |
217 | 222 |
218 } // namespace | 223 } // namespace |
219 | 224 |
220 U_CAPI int32_t U_EXPORT2 | 225 U_CAPI int32_t U_EXPORT2 |
221 uscript_getSampleString(UScriptCode script, UChar *dest, int32_t capacity, UErro
rCode *pErrorCode) { | 226 uscript_getSampleString(UScriptCode script, UChar *dest, int32_t capacity, UErro
rCode *pErrorCode) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 | 265 |
261 U_CAPI UBool U_EXPORT2 | 266 U_CAPI UBool U_EXPORT2 |
262 uscript_breaksBetweenLetters(UScriptCode script) { | 267 uscript_breaksBetweenLetters(UScriptCode script) { |
263 return (getScriptProps(script) & LB_LETTERS) != 0; | 268 return (getScriptProps(script) & LB_LETTERS) != 0; |
264 } | 269 } |
265 | 270 |
266 U_CAPI UBool U_EXPORT2 | 271 U_CAPI UBool U_EXPORT2 |
267 uscript_isCased(UScriptCode script) { | 272 uscript_isCased(UScriptCode script) { |
268 return (getScriptProps(script) & CASED) != 0; | 273 return (getScriptProps(script) & CASED) != 0; |
269 } | 274 } |
OLD | NEW |