2 *******************************************************************************
4 * Copyright (C) 2002-2008, 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.icu.
23 #include "unicode/utypes.h"
24 #include "unicode/uset.h"
28 /* indexes[] entries */
31 UPROPS_EXCEPTIONS_INDEX
,
32 UPROPS_EXCEPTIONS_TOP_INDEX
,
34 UPROPS_ADDITIONAL_TRIE_INDEX
,
35 UPROPS_ADDITIONAL_VECTORS_INDEX
,
36 UPROPS_ADDITIONAL_VECTORS_COLUMNS_INDEX
,
38 UPROPS_RESERVED_INDEX
, /* 6 */
40 /* maximum values for code values in vector word 0 */
41 UPROPS_MAX_VALUES_INDEX
=10,
42 /* maximum values for code values in vector word 2 */
43 UPROPS_MAX_VALUES_2_INDEX
,
48 /* definitions for the main properties words */
50 /* general category shift==0 0 (5 bits) */
51 UPROPS_NUMERIC_TYPE_SHIFT
=5, /* 5 (3 bits) */
52 UPROPS_NUMERIC_VALUE_SHIFT
=8 /* 8 (8 bits) */
55 #define GET_CATEGORY(props) ((props)&0x1f)
56 #define CAT_MASK(props) U_MASK(GET_CATEGORY(props))
58 #define GET_NUMERIC_TYPE(props) (((props)>>UPROPS_NUMERIC_TYPE_SHIFT)&7)
59 #define GET_NUMERIC_VALUE(props) (((props)>>UPROPS_NUMERIC_VALUE_SHIFT)&0xff)
61 /* internal numeric pseudo-types for special encodings of numeric values */
63 UPROPS_NT_FRACTION
=4, /* ==U_NT_COUNT, must not change unless binary format version changes */
68 /* encoding of fractional and large numbers */
70 UPROPS_MAX_SMALL_NUMBER
=0xff,
72 UPROPS_FRACTION_NUM_SHIFT
=3, /* numerator: bits 7..3 */
73 UPROPS_FRACTION_DEN_MASK
=7, /* denominator: bits 2..0 */
75 UPROPS_FRACTION_MAX_NUM
=31,
76 UPROPS_FRACTION_DEN_OFFSET
=2, /* denominator values are 2..9 */
78 UPROPS_FRACTION_MIN_DEN
=UPROPS_FRACTION_DEN_OFFSET
,
79 UPROPS_FRACTION_MAX_DEN
=UPROPS_FRACTION_MIN_DEN
+UPROPS_FRACTION_DEN_MASK
,
81 UPROPS_LARGE_MANT_SHIFT
=4, /* mantissa: bits 7..4 */
82 UPROPS_LARGE_EXP_MASK
=0xf, /* exponent: bits 3..0 */
83 UPROPS_LARGE_EXP_OFFSET
=2, /* regular exponents 2..17 */
84 UPROPS_LARGE_EXP_OFFSET_EXTRA
=18, /* extra large exponents 18..33 */
86 UPROPS_LARGE_MIN_EXP
=UPROPS_LARGE_EXP_OFFSET
,
87 UPROPS_LARGE_MAX_EXP
=UPROPS_LARGE_MIN_EXP
+UPROPS_LARGE_EXP_MASK
,
88 UPROPS_LARGE_MAX_EXP_EXTRA
=UPROPS_LARGE_EXP_OFFSET_EXTRA
+UPROPS_LARGE_EXP_MASK
91 /* number of properties vector words */
92 #define UPROPS_VECTOR_WORDS 3
95 * Properties in vector word 0
97 * 31..24 DerivedAge version major/minor one nibble each
99 * 19..17 East Asian Width
104 /* derived age: one nibble each for major and minor version numbers */
105 #define UPROPS_AGE_MASK 0xff000000
106 #define UPROPS_AGE_SHIFT 24
108 #define UPROPS_EA_MASK 0x000e0000
109 #define UPROPS_EA_SHIFT 17
111 #define UPROPS_BLOCK_MASK 0x0001ff00
112 #define UPROPS_BLOCK_SHIFT 8
114 #define UPROPS_SCRIPT_MASK 0x000000ff
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_".
131 UPROPS_QUOTATION_MARK
,
132 UPROPS_TERMINAL_PUNCTUATION
,
135 UPROPS_ASCII_HEX_DIGIT
,
140 UPROPS_NONCHARACTER_CODE_POINT
,
141 UPROPS_GRAPHEME_EXTEND
,
142 UPROPS_GRAPHEME_LINK
,
143 UPROPS_IDS_BINARY_OPERATOR
,
144 UPROPS_IDS_TRINARY_OPERATOR
,
146 UPROPS_UNIFIED_IDEOGRAPH
,
147 UPROPS_DEFAULT_IGNORABLE_CODE_POINT
,
149 UPROPS_LOGICAL_ORDER_EXCEPTION
,
152 UPROPS_ID_START
, /* ICU 2.6, uprops format version 3.2 */
154 UPROPS_GRAPHEME_BASE
,
155 UPROPS_S_TERM
, /* new in ICU 3.0 and Unicode 4.0.1 */
156 UPROPS_VARIATION_SELECTOR
,
157 UPROPS_PATTERN_SYNTAX
, /* new in ICU 3.4 and Unicode 4.1 */
158 UPROPS_PATTERN_WHITE_SPACE
,
159 UPROPS_RESERVED
, /* reserved & unused */
160 UPROPS_BINARY_1_TOP
/* ==32 - full! */
164 * Properties in vector word 2
168 * 19..15 Sentence Break
170 * 9.. 5 Grapheme Cluster Break
171 * 4.. 0 Decomposition Type
173 #define UPROPS_LB_MASK 0x03f00000
174 #define UPROPS_LB_SHIFT 20
175 #define UPROPS_LB_VWORD 2
177 #define UPROPS_SB_MASK 0x000f8000
178 #define UPROPS_SB_SHIFT 15
180 #define UPROPS_WB_MASK 0x00007c00
181 #define UPROPS_WB_SHIFT 10
183 #define UPROPS_GCB_MASK 0x000003e0
184 #define UPROPS_GCB_SHIFT 5
186 #define UPROPS_DT_MASK 0x0000001f
189 * Get a properties vector word for a code point.
190 * Implemented in uchar.c for uprops.c.
191 * column==-1 gets the 32-bit main properties word instead.
192 * @return 0 if no data or illegal argument
195 u_getUnicodeProperties(UChar32 c
, int32_t column
);
198 * Get the the maximum values for some enum/int properties.
199 * Use the same column numbers as for u_getUnicodeProperties().
200 * The returned value will contain maximum values stored in the same bit fields
201 * as where the enum values are stored in the u_getUnicodeProperties()
202 * return values for the same columns.
204 * Valid columns are those for properties words that contain enumerated values.
205 * (ICU 2.6: columns 0 and 2)
206 * For other column numbers, this function will return 0.
211 uprv_getMaxValues(int32_t column
);
214 * Get the Hangul Syllable Type for c.
217 U_CFUNC UHangulSyllableType
218 uchar_getHST(UChar32 c
);
221 * Checks if c is alphabetic, or a decimal digit; implements UCHAR_POSIX_ALNUM.
225 u_isalnumPOSIX(UChar32 c
);
229 * [^\p{space}\p{gc=Control}\p{gc=Surrogate}\p{gc=Unassigned}]
230 * with space=\p{Whitespace} and Control=Cc.
231 * Implements UCHAR_POSIX_GRAPH.
235 u_isgraphPOSIX(UChar32 c
);
238 * Checks if c is in \p{graph}\p{blank} - \p{cntrl}.
239 * Implements UCHAR_POSIX_PRINT.
243 u_isprintPOSIX(UChar32 c
);
245 /** Turn a bit index into a bit flag. @internal */
246 #define FLAG(n) ((uint32_t)1<<(n))
248 /** Flags for general categories in the order of UCharCategory. @internal */
249 #define _Cn FLAG(U_GENERAL_OTHER_TYPES)
250 #define _Lu FLAG(U_UPPERCASE_LETTER)
251 #define _Ll FLAG(U_LOWERCASE_LETTER)
252 #define _Lt FLAG(U_TITLECASE_LETTER)
253 #define _Lm FLAG(U_MODIFIER_LETTER)
254 #define _Lo FLAG(U_OTHER_LETTER)
255 #define _Mn FLAG(U_NON_SPACING_MARK)
256 #define _Me FLAG(U_ENCLOSING_MARK)
257 #define _Mc FLAG(U_COMBINING_SPACING_MARK)
258 #define _Nd FLAG(U_DECIMAL_DIGIT_NUMBER)
259 #define _Nl FLAG(U_LETTER_NUMBER)
260 #define _No FLAG(U_OTHER_NUMBER)
261 #define _Zs FLAG(U_SPACE_SEPARATOR)
262 #define _Zl FLAG(U_LINE_SEPARATOR)
263 #define _Zp FLAG(U_PARAGRAPH_SEPARATOR)
264 #define _Cc FLAG(U_CONTROL_CHAR)
265 #define _Cf FLAG(U_FORMAT_CHAR)
266 #define _Co FLAG(U_PRIVATE_USE_CHAR)
267 #define _Cs FLAG(U_SURROGATE)
268 #define _Pd FLAG(U_DASH_PUNCTUATION)
269 #define _Ps FLAG(U_START_PUNCTUATION)
270 #define _Pe FLAG(U_END_PUNCTUATION)
271 #define _Pc FLAG(U_CONNECTOR_PUNCTUATION)
272 #define _Po FLAG(U_OTHER_PUNCTUATION)
273 #define _Sm FLAG(U_MATH_SYMBOL)
274 #define _Sc FLAG(U_CURRENCY_SYMBOL)
275 #define _Sk FLAG(U_MODIFIER_SYMBOL)
276 #define _So FLAG(U_OTHER_SYMBOL)
277 #define _Pi FLAG(U_INITIAL_PUNCTUATION)
278 #define _Pf FLAG(U_FINAL_PUNCTUATION)
280 /** Some code points. @internal */
315 * Get the maximum length of a (regular/1.0/extended) character name.
316 * @return 0 if no character names available.
318 U_CAPI
int32_t U_EXPORT2
319 uprv_getMaxCharNameLength(void);
322 * Fills set with characters that are used in Unicode character names.
323 * Includes all characters that are used in regular/Unicode 1.0/extended names.
324 * Just empties the set if no character names are available.
325 * @param sa USetAdder to receive characters.
327 U_CAPI
void U_EXPORT2
328 uprv_getCharNameCharacters(const USetAdder
*sa
);
331 * Constants for which data and implementation files provide which properties.
332 * Used by UnicodeSet for service-specific property enumeration.
335 enum UPropertySource
{
336 /** No source, not a supported property. */
338 /** From uchar.c/uprops.icu main trie */
340 /** From uchar.c/uprops.icu properties vectors trie */
342 /** Hangul_Syllable_Type, from uchar.c/uprops.icu */
344 /** From unames.c/unames.icu */
346 /** From unorm.cpp/unorm.icu */
348 /** From ucase.c/ucase.icu */
350 /** From ubidi_props.c/ubidi.icu */
352 /** From uchar.c/uprops.icu main trie as well as properties vectors trie */
353 UPROPS_SRC_CHAR_AND_PROPSVEC
,
354 /** One more than the highest UPropertySource (UPROPS_SRC_) constant. */
357 typedef enum UPropertySource UPropertySource
;
360 * @see UPropertySource
363 U_CFUNC UPropertySource U_EXPORT2
364 uprops_getSource(UProperty which
);
367 * Enumerate uprops.icu's main data trie and add the
368 * start of each range of same properties to the set.
371 U_CFUNC
void U_EXPORT2
372 uchar_addPropertyStarts(const USetAdder
*sa
, UErrorCode
*pErrorCode
);
375 * Enumerate uprops.icu's properties vectors trie and add the
376 * start of each range of same properties to the set.
379 U_CFUNC
void U_EXPORT2
380 upropsvec_addPropertyStarts(const USetAdder
*sa
, UErrorCode
*pErrorCode
);
383 * Same as uchar_addPropertyStarts() but only for Hangul_Syllable_Type.
386 U_CFUNC
void U_EXPORT2
387 uhst_addPropertyStarts(const USetAdder
*sa
, UErrorCode
*pErrorCode
);
390 * Return a set of characters for property enumeration.
391 * For each two consecutive characters (start, limit) in the set,
392 * all of the properties for start..limit-1 are all the same.
394 * @param sa USetAdder to receive result. Existing contents are lost.
397 /*U_CFUNC void U_EXPORT2
398 uprv_getInclusions(const USetAdder *sa, UErrorCode *pErrorCode);
402 * Swap the ICU Unicode properties file. See uchar.c.
405 U_CAPI
int32_t U_EXPORT2
406 uprops_swap(const UDataSwapper
*ds
,
407 const void *inData
, int32_t length
, void *outData
,
408 UErrorCode
*pErrorCode
);
411 * Swap the ICU Unicode character names file. See uchar.c.
414 U_CAPI
int32_t U_EXPORT2
415 uchar_swapNames(const UDataSwapper
*ds
,
416 const void *inData
, int32_t length
, void *outData
,
417 UErrorCode
*pErrorCode
);