2 *******************************************************************************
4 * Copyright (C) 2002-2004, 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"
29 /* indexes[] entries */
32 UPROPS_EXCEPTIONS_INDEX
,
33 UPROPS_EXCEPTIONS_TOP_INDEX
,
35 UPROPS_ADDITIONAL_TRIE_INDEX
,
36 UPROPS_ADDITIONAL_VECTORS_INDEX
,
37 UPROPS_ADDITIONAL_VECTORS_COLUMNS_INDEX
,
39 UPROPS_RESERVED_INDEX
, /* 6 */
41 /* maximum values for code values in vector word 0 */
42 UPROPS_MAX_VALUES_INDEX
=10,
43 /* maximum values for code values in vector word 2 */
44 UPROPS_MAX_VALUES_2_INDEX
,
49 /* definitions for the main properties words */
51 /* general category shift==0 0 (5 bits) */
52 UPROPS_EXCEPTION_SHIFT
=5, /* 5 (1 bit) */
53 UPROPS_BIDI_SHIFT
, /* 6 (5 bits) */
54 UPROPS_MIRROR_SHIFT
=UPROPS_BIDI_SHIFT
+5, /* 11 (1 bit) */
55 UPROPS_NUMERIC_TYPE_SHIFT
, /* 12 (3 bits) */
56 UPROPS_CASE_SENSITIVE_SHIFT
=UPROPS_NUMERIC_TYPE_SHIFT
+3,/* 15 (1 bit) format version 3.2 */
57 UPROPS_RESERVED_SHIFT
, /* 16 (4 bits) */
58 UPROPS_VALUE_SHIFT
=20, /* 20 */
60 UPROPS_EXCEPTION_BIT
=1UL<<UPROPS_EXCEPTION_SHIFT
,
61 UPROPS_VALUE_BITS
=32-UPROPS_VALUE_SHIFT
,
63 UPROPS_MIN_VALUE
=-(1L<<(UPROPS_VALUE_BITS
-1)),
64 UPROPS_MAX_VALUE
=(1L<<(UPROPS_VALUE_BITS
-1))-1,
65 UPROPS_MAX_EXCEPTIONS_COUNT
=1L<<UPROPS_VALUE_BITS
68 #define PROPS_VALUE_IS_EXCEPTION(props) ((props)&UPROPS_EXCEPTION_BIT)
69 #define GET_CATEGORY(props) ((props)&0x1f)
70 #define GET_BIDI_CLASS(props) ((props>>UPROPS_BIDI_SHIFT)&0x1f)
71 #define GET_NUMERIC_TYPE(props) (((props)>>UPROPS_NUMERIC_TYPE_SHIFT)&7)
72 #define GET_UNSIGNED_VALUE(props) ((props)>>UPROPS_VALUE_SHIFT)
73 #define GET_SIGNED_VALUE(props) ((int32_t)(props)>>UPROPS_VALUE_SHIFT)
74 #define GET_EXCEPTIONS(props) (exceptionsTable+GET_UNSIGNED_VALUE(props))
76 #define CAT_MASK(props) U_MASK(GET_CATEGORY(props))
84 EXC_DENOMINATOR_VALUE
,
90 /* number of properties vector words */
91 #define UPROPS_VECTOR_WORDS 3
94 * Properties in vector word 0
96 * 31..24 DerivedAge version major/minor one nibble each
99 * 17..15 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_LB_MASK 0x007C0000
109 #define UPROPS_LB_SHIFT 18
111 #define UPROPS_EA_MASK 0x00038000
112 #define UPROPS_EA_SHIFT 15
114 #define UPROPS_BLOCK_MASK 0x00007f80
115 #define UPROPS_BLOCK_SHIFT 7
117 #define UPROPS_SCRIPT_MASK 0x0000007f
120 * Properties in vector word 1
121 * Each bit encodes one binary property.
122 * The following constants represent the bit number, use 1<<UPROPS_XYZ.
123 * UPROPS_BINARY_1_TOP<=32!
125 * Keep this list of property enums in sync with
126 * propListNames[] in icu/source/tools/genprops/props2.c!
128 * ICU 2.6/uprops format version 3.2 stores full properties instead of "Other_".
136 UPROPS_QUOTATION_MARK
,
137 UPROPS_TERMINAL_PUNCTUATION
,
140 UPROPS_ASCII_HEX_DIGIT
,
147 UPROPS_NONCHARACTER_CODE_POINT
,
148 UPROPS_GRAPHEME_EXTEND
,
149 UPROPS_GRAPHEME_LINK
,
150 UPROPS_IDS_BINARY_OPERATOR
,
151 UPROPS_IDS_TRINARY_OPERATOR
,
153 UPROPS_UNIFIED_IDEOGRAPH
,
154 UPROPS_DEFAULT_IGNORABLE_CODE_POINT
,
157 UPROPS_LOGICAL_ORDER_EXCEPTION
,
160 UPROPS_ID_START
, /* ICU 2.6, uprops format version 3.2 */
162 UPROPS_GRAPHEME_BASE
,
163 UPROPS_BINARY_1_TOP
/* ==32 - full! */
167 * Properties in vector word 2
169 * 31..24 More binary properties
170 * 13..11 Joining Type
171 * 10.. 5 Joining Group
172 * 4.. 0 Decomposition Type
174 #define UPROPS_JT_MASK 0x00003800
175 #define UPROPS_JT_SHIFT 11
177 #define UPROPS_JG_MASK 0x000007e0
178 #define UPROPS_JG_SHIFT 5
180 #define UPROPS_DT_MASK 0x0000001f
183 UPROPS_V2_S_TERM
=24, /* new in ICU 3.0 and Unicode 4.0.1 */
184 UPROPS_V2_VARIATION_SELECTOR
,
185 UPROPS_V2_TOP
/* must be <=32 */
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
);
220 /** Turn a bit index into a bit flag. @internal */
221 #define FLAG(n) ((uint32_t)1<<(n))
223 /** Flags for general categories in the order of UCharCategory. @internal */
224 #define _Cn FLAG(U_GENERAL_OTHER_TYPES)
225 #define _Lu FLAG(U_UPPERCASE_LETTER)
226 #define _Ll FLAG(U_LOWERCASE_LETTER)
227 #define _Lt FLAG(U_TITLECASE_LETTER)
228 #define _Lm FLAG(U_MODIFIER_LETTER)
229 #define _Lo FLAG(U_OTHER_LETTER)
230 #define _Mn FLAG(U_NON_SPACING_MARK)
231 #define _Me FLAG(U_ENCLOSING_MARK)
232 #define _Mc FLAG(U_COMBINING_SPACING_MARK)
233 #define _Nd FLAG(U_DECIMAL_DIGIT_NUMBER)
234 #define _Nl FLAG(U_LETTER_NUMBER)
235 #define _No FLAG(U_OTHER_NUMBER)
236 #define _Zs FLAG(U_SPACE_SEPARATOR)
237 #define _Zl FLAG(U_LINE_SEPARATOR)
238 #define _Zp FLAG(U_PARAGRAPH_SEPARATOR)
239 #define _Cc FLAG(U_CONTROL_CHAR)
240 #define _Cf FLAG(U_FORMAT_CHAR)
241 #define _Co FLAG(U_PRIVATE_USE_CHAR)
242 #define _Cs FLAG(U_SURROGATE)
243 #define _Pd FLAG(U_DASH_PUNCTUATION)
244 #define _Ps FLAG(U_START_PUNCTUATION)
245 #define _Pe FLAG(U_END_PUNCTUATION)
246 #define _Pc FLAG(U_CONNECTOR_PUNCTUATION)
247 #define _Po FLAG(U_OTHER_PUNCTUATION)
248 #define _Sm FLAG(U_MATH_SYMBOL)
249 #define _Sc FLAG(U_CURRENCY_SYMBOL)
250 #define _Sk FLAG(U_MODIFIER_SYMBOL)
251 #define _So FLAG(U_OTHER_SYMBOL)
252 #define _Pi FLAG(U_INITIAL_PUNCTUATION)
253 #define _Pf FLAG(U_FINAL_PUNCTUATION)
255 /** Some code points. @internal */
282 * Get the maximum length of a (regular/1.0/extended) character name.
283 * @return 0 if no character names available.
285 U_CAPI
int32_t U_EXPORT2
286 uprv_getMaxCharNameLength(void);
290 Currently not used but left for future use. Probably by UnicodeSet.
291 urename.h and unames.c changed accordingly.
294 * Get the maximum length of an ISO comment.
295 * @return 0 if no ISO comments available.
297 U_CAPI
int32_t U_EXPORT2
298 uprv_getMaxISOCommentLength();
302 * Fills set with characters that are used in Unicode character names.
303 * Includes all characters that are used in regular/Unicode 1.0/extended names.
304 * Just empties the set if no character names are available.
305 * @param sa USetAdder to receive characters.
307 U_CAPI
void U_EXPORT2
308 uprv_getCharNameCharacters(USetAdder
*sa
);
312 Currently not used but left for future use. Probably by UnicodeSet.
313 urename.h and unames.c changed accordingly.
316 * Fills set with characters that are used in Unicode character names.
317 * Just empties the set if no ISO comments are available.
318 * @param sa USetAdder to receive characters.
320 U_CAPI
void U_EXPORT2
321 uprv_getISOCommentCharacters(USetAdder
*sa
);
326 * Constants for which data and implementation files provide which properties.
327 * Used by UnicodeSet for service-specific property enumeration.
330 enum UPropertySource
{
331 /** No source, not a supported property. */
333 /** From uchar.c/uprops.icu */
335 /** Hangul_Syllable_Type, from uchar.c/uprops.icu */
337 /** From unames.c/unames.icu */
339 /** From unorm.cpp/unorm.icu */
341 /** From ucase.c/ucase.icu */
343 /** From ubidi.c/ubidi.icu */
345 /** One more than the highes UPropertySource (UPROPS_SRC_) constant. */
348 typedef enum UPropertySource UPropertySource
;
351 * @see UPropertySource
354 U_CAPI UPropertySource U_EXPORT2
355 uprops_getSource(UProperty which
);
358 * Enumerate each core properties data trie and add the
359 * start of each range of same properties to the set.
362 U_CAPI
void U_EXPORT2
363 uchar_addPropertyStarts(USetAdder
*sa
, UErrorCode
*pErrorCode
);
366 * Same as uchar_addPropertyStarts() but only for Hangul_Syllable_Type.
369 U_CAPI
void U_EXPORT2
370 uhst_addPropertyStarts(USetAdder
*sa
, UErrorCode
*pErrorCode
);
373 * Return a set of characters for property enumeration.
374 * For each two consecutive characters (start, limit) in the set,
375 * all of the properties for start..limit-1 are all the same.
377 * @param sa USetAdder to receive result. Existing contents are lost.
380 U_CAPI
void U_EXPORT2
381 uprv_getInclusions(USetAdder
*sa
, UErrorCode
*pErrorCode
);
384 * Swap the ICU Unicode properties file. See uchar.c.
387 U_CAPI
int32_t U_EXPORT2
388 uprops_swap(const UDataSwapper
*ds
,
389 const void *inData
, int32_t length
, void *outData
,
390 UErrorCode
*pErrorCode
);
393 * Swap the ICU Unicode character names file. See uchar.c.
396 U_CAPI
int32_t U_EXPORT2
397 uchar_swapNames(const UDataSwapper
*ds
,
398 const void *inData
, int32_t length
, void *outData
,
399 UErrorCode
*pErrorCode
);