]> git.saurik.com Git - apple/icu.git/blob - icuSources/common/uprops.h
ICU-3.13.tar.gz
[apple/icu.git] / icuSources / common / uprops.h
1 /*
2 *******************************************************************************
3 *
4 * Copyright (C) 2002-2003, International Business Machines
5 * Corporation and others. All Rights Reserved.
6 *
7 *******************************************************************************
8 * file name: uprops.h
9 * encoding: US-ASCII
10 * tab size: 8 (not used)
11 * indentation:4
12 *
13 * created on: 2002feb24
14 * created by: Markus W. Scherer
15 *
16 * Constants for mostly non-core Unicode character properties
17 * stored in uprops.dat.
18 */
19
20 #ifndef __UPROPS_H__
21 #define __UPROPS_H__
22
23 #include "unicode/utypes.h"
24 #include "unicode/uset.h"
25
26 /* indexes[] entries */
27 enum {
28 UPROPS_PROPS32_INDEX,
29 UPROPS_EXCEPTIONS_INDEX,
30 UPROPS_EXCEPTIONS_TOP_INDEX,
31
32 UPROPS_ADDITIONAL_TRIE_INDEX,
33 UPROPS_ADDITIONAL_VECTORS_INDEX,
34 UPROPS_ADDITIONAL_VECTORS_COLUMNS_INDEX,
35
36 UPROPS_RESERVED_INDEX, /* 6 */
37
38 /* maximum values for code values in vector word 0 */
39 UPROPS_MAX_VALUES_INDEX=10,
40 /* maximum values for code values in vector word 2 */
41 UPROPS_MAX_VALUES_2_INDEX,
42
43 UPROPS_INDEX_COUNT=16
44 };
45
46 /* definitions for the main properties words */
47 enum {
48 /* general category shift==0 0 (5 bits) */
49 UPROPS_EXCEPTION_SHIFT=5, /* 5 (1 bit) */
50 UPROPS_BIDI_SHIFT, /* 6 (5 bits) */
51 UPROPS_MIRROR_SHIFT=UPROPS_BIDI_SHIFT+5, /* 11 (1 bit) */
52 UPROPS_NUMERIC_TYPE_SHIFT, /* 12 (3 bits) */
53 UPROPS_CASE_SENSITIVE_SHIFT=UPROPS_NUMERIC_TYPE_SHIFT+3,/* 15 (1 bit) format version 3.2 */
54 UPROPS_RESERVED_SHIFT, /* 16 (4 bits) */
55 UPROPS_VALUE_SHIFT=20, /* 20 */
56
57 UPROPS_EXCEPTION_BIT=1UL<<UPROPS_EXCEPTION_SHIFT,
58 UPROPS_VALUE_BITS=32-UPROPS_VALUE_SHIFT,
59
60 UPROPS_MIN_VALUE=-(1L<<(UPROPS_VALUE_BITS-1)),
61 UPROPS_MAX_VALUE=(1L<<(UPROPS_VALUE_BITS-1))-1,
62 UPROPS_MAX_EXCEPTIONS_COUNT=1L<<UPROPS_VALUE_BITS
63 };
64
65 #define PROPS_VALUE_IS_EXCEPTION(props) ((props)&UPROPS_EXCEPTION_BIT)
66 #define GET_CATEGORY(props) ((props)&0x1f)
67 #define GET_BIDI_CLASS(props) ((props>>UPROPS_BIDI_SHIFT)&0x1f)
68 #define GET_NUMERIC_TYPE(props) (((props)>>UPROPS_NUMERIC_TYPE_SHIFT)&7)
69 #define GET_UNSIGNED_VALUE(props) ((props)>>UPROPS_VALUE_SHIFT)
70 #define GET_SIGNED_VALUE(props) ((int32_t)(props)>>UPROPS_VALUE_SHIFT)
71 #define GET_EXCEPTIONS(props) (exceptionsTable+GET_UNSIGNED_VALUE(props))
72
73 #define CAT_MASK(props) U_MASK(GET_CATEGORY(props))
74
75 enum {
76 EXC_UPPERCASE,
77 EXC_LOWERCASE,
78 EXC_TITLECASE,
79 EXC_UNUSED,
80 EXC_NUMERIC_VALUE,
81 EXC_DENOMINATOR_VALUE,
82 EXC_MIRROR_MAPPING,
83 EXC_SPECIAL_CASING,
84 EXC_CASE_FOLDING
85 };
86
87 /* number of properties vector words */
88 #define UPROPS_VECTOR_WORDS 3
89
90 /*
91 * Properties in vector word 0
92 * Bits
93 * 31..24 DerivedAge version major/minor one nibble each
94 * 23 reserved
95 * 22..18 Line Break
96 * 17..15 East Asian Width
97 * 14.. 7 UBlockCode
98 * 6.. 0 UScriptCode
99 */
100
101 /* derived age: one nibble each for major and minor version numbers */
102 #define UPROPS_AGE_MASK 0xff000000
103 #define UPROPS_AGE_SHIFT 24
104
105 #define UPROPS_LB_MASK 0x007C0000
106 #define UPROPS_LB_SHIFT 18
107
108 #define UPROPS_EA_MASK 0x00038000
109 #define UPROPS_EA_SHIFT 15
110
111 #define UPROPS_BLOCK_MASK 0x00007f80
112 #define UPROPS_BLOCK_SHIFT 7
113
114 #define UPROPS_SCRIPT_MASK 0x0000007f
115
116 /*
117 * Properties in vector word 1
118 * Each bit encodes one binary property.
119 * The following constants represent the bit number, use 1<<UPROPS_XYZ.
120 * UPROPS_BINARY_1_TOP<=32!
121 *
122 * Keep this list of property enums in sync with
123 * propListNames[] in icu/source/tools/genprops/props2.c!
124 *
125 * ICU 2.6/uprops format version 3.2 stores full properties instead of "Other_".
126 */
127 enum {
128 UPROPS_WHITE_SPACE,
129 UPROPS_BIDI_CONTROL,
130 UPROPS_JOIN_CONTROL,
131 UPROPS_DASH,
132 UPROPS_HYPHEN,
133 UPROPS_QUOTATION_MARK,
134 UPROPS_TERMINAL_PUNCTUATION,
135 UPROPS_MATH,
136 UPROPS_HEX_DIGIT,
137 UPROPS_ASCII_HEX_DIGIT,
138 UPROPS_ALPHABETIC,
139 UPROPS_IDEOGRAPHIC,
140 UPROPS_DIACRITIC,
141 UPROPS_EXTENDER,
142 UPROPS_LOWERCASE,
143 UPROPS_UPPERCASE,
144 UPROPS_NONCHARACTER_CODE_POINT,
145 UPROPS_GRAPHEME_EXTEND,
146 UPROPS_GRAPHEME_LINK,
147 UPROPS_IDS_BINARY_OPERATOR,
148 UPROPS_IDS_TRINARY_OPERATOR,
149 UPROPS_RADICAL,
150 UPROPS_UNIFIED_IDEOGRAPH,
151 UPROPS_DEFAULT_IGNORABLE_CODE_POINT,
152 UPROPS_DEPRECATED,
153 UPROPS_SOFT_DOTTED,
154 UPROPS_LOGICAL_ORDER_EXCEPTION,
155 UPROPS_XID_START,
156 UPROPS_XID_CONTINUE,
157 UPROPS_ID_START, /* ICU 2.6, uprops format version 3.2 */
158 UPROPS_ID_CONTINUE,
159 UPROPS_GRAPHEME_BASE,
160 UPROPS_BINARY_1_TOP /* ==32 - full! */
161 };
162
163 /*
164 * Properties in vector word 2
165 * Bits
166 * 13..11 Joining Type
167 * 10.. 5 Joining Group
168 * 4.. 0 Decomposition Type
169 */
170 #define UPROPS_JT_MASK 0x00003800
171 #define UPROPS_JT_SHIFT 11
172
173 #define UPROPS_JG_MASK 0x000007e0
174 #define UPROPS_JG_SHIFT 5
175
176 #define UPROPS_DT_MASK 0x0000001f
177
178 /**
179 * Get a properties vector word for a code point.
180 * Implemented in uchar.c for uprops.c.
181 * column==-1 gets the 32-bit main properties word instead.
182 * @return 0 if no data or illegal argument
183 */
184 U_CFUNC uint32_t
185 u_getUnicodeProperties(UChar32 c, int32_t column);
186
187 /**
188 * Get the the maximum values for some enum/int properties.
189 * Use the same column numbers as for u_getUnicodeProperties().
190 * The returned value will contain maximum values stored in the same bit fields
191 * as where the enum values are stored in the u_getUnicodeProperties()
192 * return values for the same columns.
193 *
194 * Valid columns are those for properties words that contain enumerated values.
195 * (ICU 2.6: columns 0 and 2)
196 * For other column numbers, this function will return 0.
197 *
198 * @internal
199 */
200 U_CFUNC int32_t
201 uprv_getMaxValues(int32_t column);
202
203 /**
204 * Unicode property names and property value names are compared
205 * "loosely". Property[Value]Aliases.txt say:
206 * "With loose matching of property names, the case distinctions, whitespace,
207 * and '_' are ignored."
208 *
209 * This function does just that, for ASCII (char *) name strings.
210 * It is almost identical to ucnv_compareNames() but also ignores
211 * ASCII White_Space characters (U+0009..U+000d).
212 *
213 * @internal
214 */
215 U_CAPI int32_t U_EXPORT2
216 uprv_comparePropertyNames(const char *name1, const char *name2);
217
218 /** Turn a bit index into a bit flag. @internal */
219 #define FLAG(n) ((uint32_t)1<<(n))
220
221 /** Flags for general categories in the order of UCharCategory. @internal */
222 #define _Cn FLAG(U_GENERAL_OTHER_TYPES)
223 #define _Lu FLAG(U_UPPERCASE_LETTER)
224 #define _Ll FLAG(U_LOWERCASE_LETTER)
225 #define _Lt FLAG(U_TITLECASE_LETTER)
226 #define _Lm FLAG(U_MODIFIER_LETTER)
227 #define _Lo FLAG(U_OTHER_LETTER)
228 #define _Mn FLAG(U_NON_SPACING_MARK)
229 #define _Me FLAG(U_ENCLOSING_MARK)
230 #define _Mc FLAG(U_COMBINING_SPACING_MARK)
231 #define _Nd FLAG(U_DECIMAL_DIGIT_NUMBER)
232 #define _Nl FLAG(U_LETTER_NUMBER)
233 #define _No FLAG(U_OTHER_NUMBER)
234 #define _Zs FLAG(U_SPACE_SEPARATOR)
235 #define _Zl FLAG(U_LINE_SEPARATOR)
236 #define _Zp FLAG(U_PARAGRAPH_SEPARATOR)
237 #define _Cc FLAG(U_CONTROL_CHAR)
238 #define _Cf FLAG(U_FORMAT_CHAR)
239 #define _Co FLAG(U_PRIVATE_USE_CHAR)
240 #define _Cs FLAG(U_SURROGATE)
241 #define _Pd FLAG(U_DASH_PUNCTUATION)
242 #define _Ps FLAG(U_START_PUNCTUATION)
243 #define _Pe FLAG(U_END_PUNCTUATION)
244 #define _Pc FLAG(U_CONNECTOR_PUNCTUATION)
245 #define _Po FLAG(U_OTHER_PUNCTUATION)
246 #define _Sm FLAG(U_MATH_SYMBOL)
247 #define _Sc FLAG(U_CURRENCY_SYMBOL)
248 #define _Sk FLAG(U_MODIFIER_SYMBOL)
249 #define _So FLAG(U_OTHER_SYMBOL)
250 #define _Pi FLAG(U_INITIAL_PUNCTUATION)
251 #define _Pf FLAG(U_FINAL_PUNCTUATION)
252
253 /** Some code points. @internal */
254 enum {
255 TAB =0x0009,
256 LF =0x000a,
257 FF =0x000c,
258 CR =0x000d,
259 U_A =0x0041,
260 U_Z =0x005a,
261 U_a =0x0061,
262 U_z =0x007a,
263 DEL =0x007f,
264 NL =0x0085,
265 NBSP =0x00a0,
266 CGJ =0x034f,
267 FIGURESP=0x2007,
268 HAIRSP =0x200a,
269 ZWNJ =0x200c,
270 ZWJ =0x200d,
271 RLM =0x200f,
272 NNBSP =0x202f,
273 WJ =0x2060,
274 INHSWAP =0x206a,
275 NOMDIG =0x206f,
276 ZWNBSP =0xfeff
277 };
278
279 /**
280 * Is this character a "white space" in the sense of ICU rule parsers?
281 * @internal
282 */
283 U_CAPI UBool U_EXPORT2
284 uprv_isRuleWhiteSpace(UChar32 c);
285
286 /**
287 * Get the set of "white space" characters in the sense of ICU rule
288 * parsers. Caller must close/delete result.
289 * @internal
290 */
291 U_CAPI USet* U_EXPORT2
292 uprv_openRuleWhiteSpaceSet(UErrorCode* ec);
293
294 /**
295 * Get the maximum length of a (regular/1.0/extended) character name.
296 * @return 0 if no character names available.
297 */
298 U_CAPI int32_t U_EXPORT2
299 uprv_getMaxCharNameLength(void);
300
301 #if 0
302 /*
303 Currently not used but left for future use. Probably by UnicodeSet.
304 urename.h and unames.c changed accordingly.
305 */
306 /**
307 * Get the maximum length of an ISO comment.
308 * @return 0 if no ISO comments available.
309 */
310 U_CAPI int32_t U_EXPORT2
311 uprv_getMaxISOCommentLength();
312 #endif
313
314 /**
315 * Fills set with characters that are used in Unicode character names.
316 * Includes all characters that are used in regular/Unicode 1.0/extended names.
317 * Just empties the set if no character names are available.
318 * @param set USet to receive characters. Existing contents are deleted.
319 */
320 U_CAPI void U_EXPORT2
321 uprv_getCharNameCharacters(USet* set);
322
323 #if 0
324 /*
325 Currently not used but left for future use. Probably by UnicodeSet.
326 urename.h and unames.c changed accordingly.
327 */
328 /**
329 * Fills set with characters that are used in Unicode character names.
330 * Just empties the set if no ISO comments are available.
331 * @param set USet to receive characters. Existing contents are deleted.
332 */
333 U_CAPI void U_EXPORT2
334 uprv_getISOCommentCharacters(USet* set);
335 */
336 #endif
337
338 /**
339 * Enumerate each core properties data trie and add the
340 * start of each range of same properties to the set.
341 * @internal
342 */
343 U_CAPI void U_EXPORT2
344 uchar_addPropertyStarts(USet *set, UErrorCode *pErrorCode);
345
346 /**
347 * Return a set of characters for property enumeration.
348 * For each two consecutive characters (start, limit) in the set,
349 * all of the properties for start..limit-1 are all the same.
350 *
351 * @param set USet to receive result. Existing contents are lost.
352 * @internal
353 */
354 U_CAPI void U_EXPORT2
355 uprv_getInclusions(USet* set, UErrorCode *pErrorCode);
356
357 #endif