2 *******************************************************************************
4 * Copyright (C) 2002-2003, International Business Machines
5 * Corporation and others. All Rights Reserved.
7 *******************************************************************************
10 * tab size: 8 (not used)
13 * created on: 2002feb24
14 * created by: Markus W. Scherer
16 * Constants for mostly non-core Unicode character properties
17 * stored in uprops.dat.
23 #include "unicode/utypes.h"
24 #include "unicode/uset.h"
26 /* indexes[] entries */
29 UPROPS_EXCEPTIONS_INDEX
,
30 UPROPS_EXCEPTIONS_TOP_INDEX
,
32 UPROPS_ADDITIONAL_TRIE_INDEX
,
33 UPROPS_ADDITIONAL_VECTORS_INDEX
,
34 UPROPS_ADDITIONAL_VECTORS_COLUMNS_INDEX
,
36 UPROPS_RESERVED_INDEX
, /* 6 */
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
,
46 /* definitions for the main properties words */
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 */
57 UPROPS_EXCEPTION_BIT
=1UL<<UPROPS_EXCEPTION_SHIFT
,
58 UPROPS_VALUE_BITS
=32-UPROPS_VALUE_SHIFT
,
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
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))
73 #define CAT_MASK(props) U_MASK(GET_CATEGORY(props))
81 EXC_DENOMINATOR_VALUE
,
87 /* number of properties vector words */
88 #define UPROPS_VECTOR_WORDS 3
91 * Properties in vector word 0
93 * 31..24 DerivedAge version major/minor one nibble each
96 * 17..15 East Asian Width
101 /* derived age: one nibble each for major and minor version numbers */
102 #define UPROPS_AGE_MASK 0xff000000
103 #define UPROPS_AGE_SHIFT 24
105 #define UPROPS_LB_MASK 0x007C0000
106 #define UPROPS_LB_SHIFT 18
108 #define UPROPS_EA_MASK 0x00038000
109 #define UPROPS_EA_SHIFT 15
111 #define UPROPS_BLOCK_MASK 0x00007f80
112 #define UPROPS_BLOCK_SHIFT 7
114 #define UPROPS_SCRIPT_MASK 0x0000007f
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!
122 * Keep this list of property enums in sync with
123 * propListNames[] in icu/source/tools/genprops/props2.c!
125 * ICU 2.6/uprops format version 3.2 stores full properties instead of "Other_".
133 UPROPS_QUOTATION_MARK
,
134 UPROPS_TERMINAL_PUNCTUATION
,
137 UPROPS_ASCII_HEX_DIGIT
,
144 UPROPS_NONCHARACTER_CODE_POINT
,
145 UPROPS_GRAPHEME_EXTEND
,
146 UPROPS_GRAPHEME_LINK
,
147 UPROPS_IDS_BINARY_OPERATOR
,
148 UPROPS_IDS_TRINARY_OPERATOR
,
150 UPROPS_UNIFIED_IDEOGRAPH
,
151 UPROPS_DEFAULT_IGNORABLE_CODE_POINT
,
154 UPROPS_LOGICAL_ORDER_EXCEPTION
,
157 UPROPS_ID_START
, /* ICU 2.6, uprops format version 3.2 */
159 UPROPS_GRAPHEME_BASE
,
160 UPROPS_BINARY_1_TOP
/* ==32 - full! */
164 * Properties in vector word 2
166 * 13..11 Joining Type
167 * 10.. 5 Joining Group
168 * 4.. 0 Decomposition Type
170 #define UPROPS_JT_MASK 0x00003800
171 #define UPROPS_JT_SHIFT 11
173 #define UPROPS_JG_MASK 0x000007e0
174 #define UPROPS_JG_SHIFT 5
176 #define UPROPS_DT_MASK 0x0000001f
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
185 u_getUnicodeProperties(UChar32 c
, int32_t column
);
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.
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.
201 uprv_getMaxValues(int32_t column
);
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."
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).
215 U_CAPI
int32_t U_EXPORT2
216 uprv_comparePropertyNames(const char *name1
, const char *name2
);
218 /** Turn a bit index into a bit flag. @internal */
219 #define FLAG(n) ((uint32_t)1<<(n))
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)
253 /** Some code points. @internal */
280 * Is this character a "white space" in the sense of ICU rule parsers?
283 U_CAPI UBool U_EXPORT2
284 uprv_isRuleWhiteSpace(UChar32 c
);
287 * Get the set of "white space" characters in the sense of ICU rule
288 * parsers. Caller must close/delete result.
291 U_CAPI USet
* U_EXPORT2
292 uprv_openRuleWhiteSpaceSet(UErrorCode
* ec
);
295 * Get the maximum length of a (regular/1.0/extended) character name.
296 * @return 0 if no character names available.
298 U_CAPI
int32_t U_EXPORT2
299 uprv_getMaxCharNameLength(void);
303 Currently not used but left for future use. Probably by UnicodeSet.
304 urename.h and unames.c changed accordingly.
307 * Get the maximum length of an ISO comment.
308 * @return 0 if no ISO comments available.
310 U_CAPI
int32_t U_EXPORT2
311 uprv_getMaxISOCommentLength();
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.
320 U_CAPI
void U_EXPORT2
321 uprv_getCharNameCharacters(USet
* set
);
325 Currently not used but left for future use. Probably by UnicodeSet.
326 urename.h and unames.c changed accordingly.
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.
333 U_CAPI
void U_EXPORT2
334 uprv_getISOCommentCharacters(USet
* set
);
339 * Enumerate each core properties data trie and add the
340 * start of each range of same properties to the set.
343 U_CAPI
void U_EXPORT2
344 uchar_addPropertyStarts(USet
*set
, UErrorCode
*pErrorCode
);
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.
351 * @param set USet to receive result. Existing contents are lost.
354 U_CAPI
void U_EXPORT2
355 uprv_getInclusions(USet
* set
, UErrorCode
*pErrorCode
);