/*
*******************************************************************************
*
-* Copyright (C) 2002-2003, International Business Machines
+* Copyright (C) 2002-2012, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
* created by: Markus W. Scherer
*
* Constants for mostly non-core Unicode character properties
-* stored in uprops.dat.
+* stored in uprops.icu.
*/
#ifndef __UPROPS_H__
#include "unicode/utypes.h"
#include "unicode/uset.h"
+#include "uset_imp.h"
+#include "udataswp.h"
/* indexes[] entries */
enum {
UPROPS_ADDITIONAL_VECTORS_INDEX,
UPROPS_ADDITIONAL_VECTORS_COLUMNS_INDEX,
- UPROPS_RESERVED_INDEX, /* 6 */
+ UPROPS_SCRIPT_EXTENSIONS_INDEX,
+
+ UPROPS_RESERVED_INDEX_7,
+ UPROPS_RESERVED_INDEX_8,
+
+ /* size of the data file (number of 32-bit units after the header) */
+ UPROPS_DATA_TOP_INDEX,
/* maximum values for code values in vector word 0 */
UPROPS_MAX_VALUES_INDEX=10,
/* definitions for the main properties words */
enum {
/* general category shift==0 0 (5 bits) */
- UPROPS_EXCEPTION_SHIFT=5, /* 5 (1 bit) */
- UPROPS_BIDI_SHIFT, /* 6 (5 bits) */
- UPROPS_MIRROR_SHIFT=UPROPS_BIDI_SHIFT+5, /* 11 (1 bit) */
- UPROPS_NUMERIC_TYPE_SHIFT, /* 12 (3 bits) */
- UPROPS_CASE_SENSITIVE_SHIFT=UPROPS_NUMERIC_TYPE_SHIFT+3,/* 15 (1 bit) format version 3.2 */
- UPROPS_RESERVED_SHIFT, /* 16 (4 bits) */
- UPROPS_VALUE_SHIFT=20, /* 20 */
-
- UPROPS_EXCEPTION_BIT=1UL<<UPROPS_EXCEPTION_SHIFT,
- UPROPS_VALUE_BITS=32-UPROPS_VALUE_SHIFT,
-
- UPROPS_MIN_VALUE=-(1L<<(UPROPS_VALUE_BITS-1)),
- UPROPS_MAX_VALUE=(1L<<(UPROPS_VALUE_BITS-1))-1,
- UPROPS_MAX_EXCEPTIONS_COUNT=1L<<UPROPS_VALUE_BITS
+ /* reserved 5 (1 bit) */
+ UPROPS_NUMERIC_TYPE_VALUE_SHIFT=6 /* 6 (10 bits) */
};
-#define PROPS_VALUE_IS_EXCEPTION(props) ((props)&UPROPS_EXCEPTION_BIT)
#define GET_CATEGORY(props) ((props)&0x1f)
-#define GET_BIDI_CLASS(props) ((props>>UPROPS_BIDI_SHIFT)&0x1f)
-#define GET_NUMERIC_TYPE(props) (((props)>>UPROPS_NUMERIC_TYPE_SHIFT)&7)
-#define GET_UNSIGNED_VALUE(props) ((props)>>UPROPS_VALUE_SHIFT)
-#define GET_SIGNED_VALUE(props) ((int32_t)(props)>>UPROPS_VALUE_SHIFT)
-#define GET_EXCEPTIONS(props) (exceptionsTable+GET_UNSIGNED_VALUE(props))
-
#define CAT_MASK(props) U_MASK(GET_CATEGORY(props))
+#define GET_NUMERIC_TYPE_VALUE(props) ((props)>>UPROPS_NUMERIC_TYPE_VALUE_SHIFT)
+
+/* constants for the storage form of numeric types and values */
enum {
- EXC_UPPERCASE,
- EXC_LOWERCASE,
- EXC_TITLECASE,
- EXC_UNUSED,
- EXC_NUMERIC_VALUE,
- EXC_DENOMINATOR_VALUE,
- EXC_MIRROR_MAPPING,
- EXC_SPECIAL_CASING,
- EXC_CASE_FOLDING
+ /** No numeric value. */
+ UPROPS_NTV_NONE=0,
+ /** Decimal digits: nv=0..9 */
+ UPROPS_NTV_DECIMAL_START=1,
+ /** Other digits: nv=0..9 */
+ UPROPS_NTV_DIGIT_START=11,
+ /** Small integers: nv=0..154 */
+ UPROPS_NTV_NUMERIC_START=21,
+ /** Fractions: ((ntv>>4)-12) / ((ntv&0xf)+1) = -1..17 / 1..16 */
+ UPROPS_NTV_FRACTION_START=0xb0,
+ /**
+ * Large integers:
+ * ((ntv>>5)-14) * 10^((ntv&0x1f)+2) = (1..9)*(10^2..10^33)
+ * (only one significant decimal digit)
+ */
+ UPROPS_NTV_LARGE_START=0x1e0,
+ /**
+ * Sexagesimal numbers:
+ * ((ntv>>2)-0xbf) * 60^((ntv&3)+1) = (1..9)*(60^1..60^4)
+ */
+ UPROPS_NTV_BASE60_START=0x300,
+ /** No numeric value (yet). */
+ UPROPS_NTV_RESERVED_START=UPROPS_NTV_BASE60_START+36, /* 0x300+9*4=0x324 */
+
+ UPROPS_NTV_MAX_SMALL_INT=UPROPS_NTV_FRACTION_START-UPROPS_NTV_NUMERIC_START-1
};
+#define UPROPS_NTV_GET_TYPE(ntv) \
+ ((ntv==UPROPS_NTV_NONE) ? U_NT_NONE : \
+ (ntv<UPROPS_NTV_DIGIT_START) ? U_NT_DECIMAL : \
+ (ntv<UPROPS_NTV_NUMERIC_START) ? U_NT_DIGIT : \
+ U_NT_NUMERIC)
+
/* number of properties vector words */
#define UPROPS_VECTOR_WORDS 3
* Properties in vector word 0
* Bits
* 31..24 DerivedAge version major/minor one nibble each
- * 23 reserved
- * 22..18 Line Break
- * 17..15 East Asian Width
- * 14.. 7 UBlockCode
- * 6.. 0 UScriptCode
+ * 23..22 3..1: Bits 7..0 = Script_Extensions index
+ * 3: Script value from Script_Extensions
+ * 2: Script=Inherited
+ * 1: Script=Common
+ * 0: Script=bits 7..0
+ * 21..20 reserved
+ * 19..17 East Asian Width
+ * 16.. 8 UBlockCode
+ * 7.. 0 UScriptCode, or index to Script_Extensions
*/
/* derived age: one nibble each for major and minor version numbers */
#define UPROPS_AGE_MASK 0xff000000
#define UPROPS_AGE_SHIFT 24
-#define UPROPS_LB_MASK 0x007C0000
-#define UPROPS_LB_SHIFT 18
+/* Script_Extensions: mask includes Script */
+#define UPROPS_SCRIPT_X_MASK 0x00c000ff
+#define UPROPS_SCRIPT_X_SHIFT 22
-#define UPROPS_EA_MASK 0x00038000
-#define UPROPS_EA_SHIFT 15
+#define UPROPS_EA_MASK 0x000e0000
+#define UPROPS_EA_SHIFT 17
-#define UPROPS_BLOCK_MASK 0x00007f80
-#define UPROPS_BLOCK_SHIFT 7
+#define UPROPS_BLOCK_MASK 0x0001ff00
+#define UPROPS_BLOCK_SHIFT 8
-#define UPROPS_SCRIPT_MASK 0x0000007f
+#define UPROPS_SCRIPT_MASK 0x000000ff
+
+/* UPROPS_SCRIPT_X_WITH_COMMON must be the lowest value that involves Script_Extensions. */
+#define UPROPS_SCRIPT_X_WITH_COMMON 0x400000
+#define UPROPS_SCRIPT_X_WITH_INHERITED 0x800000
+#define UPROPS_SCRIPT_X_WITH_OTHER 0xc00000
/*
* Properties in vector word 1
*/
enum {
UPROPS_WHITE_SPACE,
- UPROPS_BIDI_CONTROL,
- UPROPS_JOIN_CONTROL,
UPROPS_DASH,
UPROPS_HYPHEN,
UPROPS_QUOTATION_MARK,
UPROPS_IDEOGRAPHIC,
UPROPS_DIACRITIC,
UPROPS_EXTENDER,
- UPROPS_LOWERCASE,
- UPROPS_UPPERCASE,
UPROPS_NONCHARACTER_CODE_POINT,
UPROPS_GRAPHEME_EXTEND,
UPROPS_GRAPHEME_LINK,
UPROPS_UNIFIED_IDEOGRAPH,
UPROPS_DEFAULT_IGNORABLE_CODE_POINT,
UPROPS_DEPRECATED,
- UPROPS_SOFT_DOTTED,
UPROPS_LOGICAL_ORDER_EXCEPTION,
UPROPS_XID_START,
UPROPS_XID_CONTINUE,
UPROPS_ID_START, /* ICU 2.6, uprops format version 3.2 */
UPROPS_ID_CONTINUE,
UPROPS_GRAPHEME_BASE,
+ UPROPS_S_TERM, /* new in ICU 3.0 and Unicode 4.0.1 */
+ UPROPS_VARIATION_SELECTOR,
+ UPROPS_PATTERN_SYNTAX, /* new in ICU 3.4 and Unicode 4.1 */
+ UPROPS_PATTERN_WHITE_SPACE,
+ UPROPS_RESERVED, /* reserved & unused */
UPROPS_BINARY_1_TOP /* ==32 - full! */
};
/*
* Properties in vector word 2
* Bits
- * 13..11 Joining Type
- * 10.. 5 Joining Group
+ * 31..26 reserved
+ * 25..20 Line Break
+ * 19..15 Sentence Break
+ * 14..10 Word Break
+ * 9.. 5 Grapheme Cluster Break
* 4.. 0 Decomposition Type
*/
-#define UPROPS_JT_MASK 0x00003800
-#define UPROPS_JT_SHIFT 11
+#define UPROPS_LB_MASK 0x03f00000
+#define UPROPS_LB_SHIFT 20
+
+#define UPROPS_SB_MASK 0x000f8000
+#define UPROPS_SB_SHIFT 15
-#define UPROPS_JG_MASK 0x000007e0
-#define UPROPS_JG_SHIFT 5
+#define UPROPS_WB_MASK 0x00007c00
+#define UPROPS_WB_SHIFT 10
+
+#define UPROPS_GCB_MASK 0x000003e0
+#define UPROPS_GCB_SHIFT 5
#define UPROPS_DT_MASK 0x0000001f
+/**
+ * Gets the main properties value for a code point.
+ * Implemented in uchar.c for uprops.cpp.
+ */
+U_CFUNC uint32_t
+u_getMainProperties(UChar32 c);
+
/**
* Get a properties vector word for a code point.
- * Implemented in uchar.c for uprops.c.
- * column==-1 gets the 32-bit main properties word instead.
+ * Implemented in uchar.c for uprops.cpp.
* @return 0 if no data or illegal argument
*/
U_CFUNC uint32_t
uprv_getMaxValues(int32_t column);
/**
- * Unicode property names and property value names are compared
- * "loosely". Property[Value]Aliases.txt say:
- * "With loose matching of property names, the case distinctions, whitespace,
- * and '_' are ignored."
- *
- * This function does just that, for ASCII (char *) name strings.
- * It is almost identical to ucnv_compareNames() but also ignores
- * ASCII White_Space characters (U+0009..U+000d).
- *
+ * Checks if c is alphabetic, or a decimal digit; implements UCHAR_POSIX_ALNUM.
* @internal
*/
-U_CAPI int32_t U_EXPORT2
-uprv_comparePropertyNames(const char *name1, const char *name2);
+U_CFUNC UBool
+u_isalnumPOSIX(UChar32 c);
+
+/**
+ * Checks if c is in
+ * [^\p{space}\p{gc=Control}\p{gc=Surrogate}\p{gc=Unassigned}]
+ * with space=\p{Whitespace} and Control=Cc.
+ * Implements UCHAR_POSIX_GRAPH.
+ * @internal
+ */
+U_CFUNC UBool
+u_isgraphPOSIX(UChar32 c);
+
+/**
+ * Checks if c is in \p{graph}\p{blank} - \p{cntrl}.
+ * Implements UCHAR_POSIX_PRINT.
+ * @internal
+ */
+U_CFUNC UBool
+u_isprintPOSIX(UChar32 c);
/** Turn a bit index into a bit flag. @internal */
#define FLAG(n) ((uint32_t)1<<(n))
#define _Ll FLAG(U_LOWERCASE_LETTER)
#define _Lt FLAG(U_TITLECASE_LETTER)
#define _Lm FLAG(U_MODIFIER_LETTER)
-#define _Lo FLAG(U_OTHER_LETTER)
+/* #define _Lo FLAG(U_OTHER_LETTER) -- conflicts with MS Visual Studio 9.0 xiosbase */
#define _Mn FLAG(U_NON_SPACING_MARK)
#define _Me FLAG(U_ENCLOSING_MARK)
#define _Mc FLAG(U_COMBINING_SPACING_MARK)
#define _Cs FLAG(U_SURROGATE)
#define _Pd FLAG(U_DASH_PUNCTUATION)
#define _Ps FLAG(U_START_PUNCTUATION)
-#define _Pe FLAG(U_END_PUNCTUATION)
-#define _Pc FLAG(U_CONNECTOR_PUNCTUATION)
+/* #define _Pe FLAG(U_END_PUNCTUATION) -- conflicts with MS Visual Studio 9.0 xlocnum */
+/* #define _Pc FLAG(U_CONNECTOR_PUNCTUATION) -- conflicts with MS Visual Studio 9.0 streambuf */
#define _Po FLAG(U_OTHER_PUNCTUATION)
#define _Sm FLAG(U_MATH_SYMBOL)
#define _Sc FLAG(U_CURRENCY_SYMBOL)
#define _Sk FLAG(U_MODIFIER_SYMBOL)
#define _So FLAG(U_OTHER_SYMBOL)
#define _Pi FLAG(U_INITIAL_PUNCTUATION)
-#define _Pf FLAG(U_FINAL_PUNCTUATION)
+/* #define _Pf FLAG(U_FINAL_PUNCTUATION) -- conflicts with MS Visual Studio 9.0 streambuf */
/** Some code points. @internal */
enum {
FF =0x000c,
CR =0x000d,
U_A =0x0041,
+ U_F =0x0046,
U_Z =0x005a,
U_a =0x0061,
+ U_f =0x0066,
U_z =0x007a,
DEL =0x007f,
NL =0x0085,
WJ =0x2060,
INHSWAP =0x206a,
NOMDIG =0x206f,
+ U_FW_A =0xff21,
+ U_FW_F =0xff26,
+ U_FW_Z =0xff3a,
+ U_FW_a =0xff41,
+ U_FW_f =0xff46,
+ U_FW_z =0xff5a,
ZWNBSP =0xfeff
};
-/**
- * Is this character a "white space" in the sense of ICU rule parsers?
- * @internal
- */
-U_CAPI UBool U_EXPORT2
-uprv_isRuleWhiteSpace(UChar32 c);
-
-/**
- * Get the set of "white space" characters in the sense of ICU rule
- * parsers. Caller must close/delete result.
- * @internal
- */
-U_CAPI USet* U_EXPORT2
-uprv_openRuleWhiteSpaceSet(UErrorCode* ec);
-
/**
* Get the maximum length of a (regular/1.0/extended) character name.
* @return 0 if no character names available.
U_CAPI int32_t U_EXPORT2
uprv_getMaxCharNameLength(void);
-#if 0
-/*
-Currently not used but left for future use. Probably by UnicodeSet.
-urename.h and unames.c changed accordingly.
-*/
-/**
- * Get the maximum length of an ISO comment.
- * @return 0 if no ISO comments available.
- */
-U_CAPI int32_t U_EXPORT2
-uprv_getMaxISOCommentLength();
-#endif
-
/**
* Fills set with characters that are used in Unicode character names.
* Includes all characters that are used in regular/Unicode 1.0/extended names.
* Just empties the set if no character names are available.
- * @param set USet to receive characters. Existing contents are deleted.
+ * @param sa USetAdder to receive characters.
*/
U_CAPI void U_EXPORT2
-uprv_getCharNameCharacters(USet* set);
+uprv_getCharNameCharacters(const USetAdder *sa);
-#if 0
-/*
-Currently not used but left for future use. Probably by UnicodeSet.
-urename.h and unames.c changed accordingly.
-*/
/**
- * Fills set with characters that are used in Unicode character names.
- * Just empties the set if no ISO comments are available.
- * @param set USet to receive characters. Existing contents are deleted.
+ * Constants for which data and implementation files provide which properties.
+ * Used by UnicodeSet for service-specific property enumeration.
+ * @internal
*/
-U_CAPI void U_EXPORT2
-uprv_getISOCommentCharacters(USet* set);
-*/
-#endif
+enum UPropertySource {
+ /** No source, not a supported property. */
+ UPROPS_SRC_NONE,
+ /** From uchar.c/uprops.icu main trie */
+ UPROPS_SRC_CHAR,
+ /** From uchar.c/uprops.icu properties vectors trie */
+ UPROPS_SRC_PROPSVEC,
+ /** From unames.c/unames.icu */
+ UPROPS_SRC_NAMES,
+ /** From ucase.c/ucase.icu */
+ UPROPS_SRC_CASE,
+ /** From ubidi_props.c/ubidi.icu */
+ UPROPS_SRC_BIDI,
+ /** From uchar.c/uprops.icu main trie as well as properties vectors trie */
+ UPROPS_SRC_CHAR_AND_PROPSVEC,
+ /** From ucase.c/ucase.icu as well as unorm.cpp/unorm.icu */
+ UPROPS_SRC_CASE_AND_NORM,
+ /** From normalizer2impl.cpp/nfc.nrm */
+ UPROPS_SRC_NFC,
+ /** From normalizer2impl.cpp/nfkc.nrm */
+ UPROPS_SRC_NFKC,
+ /** From normalizer2impl.cpp/nfkc_cf.nrm */
+ UPROPS_SRC_NFKC_CF,
+ /** From normalizer2impl.cpp/nfc.nrm canonical iterator data */
+ UPROPS_SRC_NFC_CANON_ITER,
+ /** One more than the highest UPropertySource (UPROPS_SRC_) constant. */
+ UPROPS_SRC_COUNT
+};
+typedef enum UPropertySource UPropertySource;
+
+/**
+ * @see UPropertySource
+ * @internal
+ */
+U_CFUNC UPropertySource U_EXPORT2
+uprops_getSource(UProperty which);
/**
- * Enumerate each core properties data trie and add the
+ * Enumerate uprops.icu's main data trie and add the
* start of each range of same properties to the set.
* @internal
*/
-U_CAPI void U_EXPORT2
-uchar_addPropertyStarts(USet *set, UErrorCode *pErrorCode);
+U_CFUNC void U_EXPORT2
+uchar_addPropertyStarts(const USetAdder *sa, UErrorCode *pErrorCode);
+
+/**
+ * Enumerate uprops.icu's properties vectors trie and add the
+ * start of each range of same properties to the set.
+ * @internal
+ */
+U_CFUNC void U_EXPORT2
+upropsvec_addPropertyStarts(const USetAdder *sa, UErrorCode *pErrorCode);
/**
* Return a set of characters for property enumeration.
* For each two consecutive characters (start, limit) in the set,
* all of the properties for start..limit-1 are all the same.
*
- * @param set USet to receive result. Existing contents are lost.
+ * @param sa USetAdder to receive result. Existing contents are lost.
* @internal
*/
-U_CAPI void U_EXPORT2
-uprv_getInclusions(USet* set, UErrorCode *pErrorCode);
+/*U_CFUNC void U_EXPORT2
+uprv_getInclusions(const USetAdder *sa, UErrorCode *pErrorCode);
+*/
+
+/**
+ * Swap the ICU Unicode character names file. See uchar.c.
+ * @internal
+ */
+U_CAPI int32_t U_EXPORT2
+uchar_swapNames(const UDataSwapper *ds,
+ const void *inData, int32_t length, void *outData,
+ UErrorCode *pErrorCode);
+
+#ifdef __cplusplus
+
+U_NAMESPACE_BEGIN
+
+class UnicodeSet;
+
+// implemented in uniset_props.cpp
+U_CFUNC UnicodeSet *
+uniset_getUnicode32Instance(UErrorCode &errorCode);
+
+U_NAMESPACE_END
+
+#endif
#endif