2002-02-25 22:43:04 +00:00
|
|
|
/*
|
|
|
|
*******************************************************************************
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002, International Business Machines
|
|
|
|
* Corporation and others. All Rights Reserved.
|
|
|
|
*
|
|
|
|
*******************************************************************************
|
|
|
|
* file name: uprops.h
|
|
|
|
* encoding: US-ASCII
|
|
|
|
* tab size: 8 (not used)
|
|
|
|
* indentation:4
|
|
|
|
*
|
|
|
|
* created on: 2002feb24
|
|
|
|
* created by: Markus W. Scherer
|
|
|
|
*
|
|
|
|
* Implementations for mostly non-core Unicode character properties
|
2002-07-17 19:25:18 +00:00
|
|
|
* stored in uprops.icu.
|
2002-02-25 22:43:04 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "unicode/utypes.h"
|
|
|
|
#include "unicode/uchar.h"
|
2002-03-01 01:59:59 +00:00
|
|
|
#include "unicode/uscript.h"
|
2002-06-01 00:33:55 +00:00
|
|
|
#include "cstring.h"
|
2002-03-07 19:57:23 +00:00
|
|
|
#include "unormimp.h"
|
2002-02-25 22:43:04 +00:00
|
|
|
#include "uprops.h"
|
|
|
|
|
2003-03-07 21:49:09 +00:00
|
|
|
#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
|
|
|
|
|
2002-06-01 00:33:55 +00:00
|
|
|
/**
|
|
|
|
* 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).
|
|
|
|
*
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
U_CAPI int32_t U_EXPORT2
|
|
|
|
uprv_comparePropertyNames(const char *name1, const char *name2) {
|
|
|
|
int32_t rc;
|
|
|
|
unsigned char c1, c2;
|
|
|
|
|
|
|
|
for(;;) {
|
|
|
|
/* Ignore delimiters '-', '_', and ASCII White_Space */
|
|
|
|
while((c1=(unsigned char)*name1)=='-' || c1=='_' ||
|
|
|
|
c1==' ' || c1=='\t' || c1=='\n' || c1=='\v' || c1=='\f' || c1=='\r'
|
|
|
|
) {
|
|
|
|
++name1;
|
|
|
|
}
|
|
|
|
while((c2=(unsigned char)*name2)=='-' || c2=='_' ||
|
|
|
|
c2==' ' || c2=='\t' || c2=='\n' || c2=='\v' || c2=='\f' || c2=='\r'
|
|
|
|
) {
|
|
|
|
++name2;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If we reach the ends of both strings then they match */
|
|
|
|
if((c1|c2)==0) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Case-insensitive comparison */
|
|
|
|
if(c1!=c2) {
|
|
|
|
rc=(int32_t)(unsigned char)uprv_tolower(c1)-(int32_t)(unsigned char)uprv_tolower(c2);
|
|
|
|
if(rc!=0) {
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
++name1;
|
|
|
|
++name2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-03-06 23:31:11 +00:00
|
|
|
/* API functions ------------------------------------------------------------ */
|
|
|
|
|
2002-02-25 22:43:04 +00:00
|
|
|
U_CAPI void U_EXPORT2
|
|
|
|
u_charAge(UChar32 c, UVersionInfo versionArray) {
|
|
|
|
if(versionArray!=NULL) {
|
|
|
|
uint32_t version=u_getUnicodeProperties(c, 0)>>UPROPS_AGE_SHIFT;
|
|
|
|
versionArray[0]=(uint8_t)(version>>4);
|
|
|
|
versionArray[1]=(uint8_t)(version&0xf);
|
|
|
|
versionArray[2]=versionArray[3]=0;
|
|
|
|
}
|
|
|
|
}
|
2002-03-01 01:59:59 +00:00
|
|
|
|
|
|
|
U_CAPI UScriptCode U_EXPORT2
|
|
|
|
uscript_getScript(UChar32 c, UErrorCode *pErrorCode) {
|
|
|
|
if(pErrorCode==NULL || U_FAILURE(*pErrorCode)) {
|
2002-11-13 20:03:11 +00:00
|
|
|
return 0;
|
2002-03-01 01:59:59 +00:00
|
|
|
}
|
|
|
|
if((uint32_t)c>0x10ffff) {
|
|
|
|
*pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
|
2002-11-13 20:03:11 +00:00
|
|
|
return 0;
|
2002-03-01 01:59:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return (UScriptCode)(u_getUnicodeProperties(c, 0)&UPROPS_SCRIPT_MASK);
|
|
|
|
}
|
2002-03-02 02:26:19 +00:00
|
|
|
|
|
|
|
U_CAPI UBlockCode U_EXPORT2
|
|
|
|
ublock_getCode(UChar32 c) {
|
2003-03-04 00:52:07 +00:00
|
|
|
return (UBlockCode)((u_getUnicodeProperties(c, 0)&UPROPS_BLOCK_MASK)>>UPROPS_BLOCK_SHIFT);
|
2002-03-02 02:26:19 +00:00
|
|
|
}
|
2002-03-06 23:31:11 +00:00
|
|
|
|
2003-03-07 21:49:09 +00:00
|
|
|
static const struct {
|
|
|
|
int32_t column;
|
|
|
|
uint32_t mask;
|
|
|
|
} binProps[]={
|
|
|
|
/*
|
|
|
|
* column and mask values for binary properties from u_getUnicodeProperties().
|
|
|
|
* Must be in order of corresponding UProperty,
|
|
|
|
* and there must be exacly one entry per binary UProperty.
|
|
|
|
*/
|
|
|
|
{ 1, U_MASK(UPROPS_ALPHABETIC) },
|
|
|
|
{ 1, U_MASK(UPROPS_ASCII_HEX_DIGIT) },
|
|
|
|
{ 1, U_MASK(UPROPS_BIDI_CONTROL) },
|
|
|
|
{ -1, U_MASK(UPROPS_MIRROR_SHIFT) },
|
|
|
|
{ 1, U_MASK(UPROPS_DASH) },
|
|
|
|
{ 1, U_MASK(UPROPS_DEFAULT_IGNORABLE_CODE_POINT) },
|
|
|
|
{ 1, U_MASK(UPROPS_DEPRECATED) },
|
|
|
|
{ 1, U_MASK(UPROPS_DIACRITIC) },
|
|
|
|
{ 1, U_MASK(UPROPS_EXTENDER) },
|
|
|
|
{ 0, 0 }, /* UCHAR_FULL_COMPOSITION_EXCLUSION */
|
|
|
|
{ 1, U_MASK(UPROPS_GRAPHEME_BASE) },
|
|
|
|
{ 1, U_MASK(UPROPS_GRAPHEME_EXTEND) },
|
|
|
|
{ 1, U_MASK(UPROPS_GRAPHEME_LINK) },
|
|
|
|
{ 1, U_MASK(UPROPS_HEX_DIGIT) },
|
|
|
|
{ 1, U_MASK(UPROPS_HYPHEN) },
|
|
|
|
{ 1, U_MASK(UPROPS_ID_CONTINUE) },
|
|
|
|
{ 1, U_MASK(UPROPS_ID_START) },
|
|
|
|
{ 1, U_MASK(UPROPS_IDEOGRAPHIC) },
|
|
|
|
{ 1, U_MASK(UPROPS_IDS_BINARY_OPERATOR) },
|
|
|
|
{ 1, U_MASK(UPROPS_IDS_TRINARY_OPERATOR) },
|
|
|
|
{ 1, U_MASK(UPROPS_JOIN_CONTROL) },
|
|
|
|
{ 1, U_MASK(UPROPS_LOGICAL_ORDER_EXCEPTION) },
|
|
|
|
{ 1, U_MASK(UPROPS_LOWERCASE) },
|
|
|
|
{ 1, U_MASK(UPROPS_MATH) },
|
|
|
|
{ 1, U_MASK(UPROPS_NONCHARACTER_CODE_POINT) },
|
|
|
|
{ 1, U_MASK(UPROPS_QUOTATION_MARK) },
|
|
|
|
{ 1, U_MASK(UPROPS_RADICAL) },
|
|
|
|
{ 1, U_MASK(UPROPS_SOFT_DOTTED) },
|
|
|
|
{ 1, U_MASK(UPROPS_TERMINAL_PUNCTUATION) },
|
|
|
|
{ 1, U_MASK(UPROPS_UNIFIED_IDEOGRAPH) },
|
|
|
|
{ 1, U_MASK(UPROPS_UPPERCASE) },
|
|
|
|
{ 1, U_MASK(UPROPS_WHITE_SPACE) },
|
|
|
|
{ 1, U_MASK(UPROPS_XID_CONTINUE) },
|
|
|
|
{ 1, U_MASK(UPROPS_XID_START) },
|
|
|
|
{ -1, U_MASK(UPROPS_CASE_SENSITIVE_SHIFT) }
|
|
|
|
};
|
|
|
|
|
2002-03-12 19:09:08 +00:00
|
|
|
U_CAPI UBool U_EXPORT2
|
|
|
|
u_hasBinaryProperty(UChar32 c, UProperty which) {
|
2002-03-06 23:31:11 +00:00
|
|
|
/* c is range-checked in the functions that are called from here */
|
2003-03-07 21:49:09 +00:00
|
|
|
if(which<UCHAR_BINARY_START || UCHAR_BINARY_LIMIT<=which) {
|
2002-03-06 23:31:11 +00:00
|
|
|
/* not a known binary property */
|
|
|
|
return FALSE;
|
2003-03-07 21:49:09 +00:00
|
|
|
} else if(which==UCHAR_CASE_SENSITIVE) {
|
|
|
|
return uprv_isCaseSensitive(c);
|
|
|
|
} else if(which==UCHAR_FULL_COMPOSITION_EXCLUSION) {
|
|
|
|
return unorm_internalIsFullCompositionExclusion(c);
|
|
|
|
} else {
|
|
|
|
/* systematic, directly stored properties */
|
|
|
|
return (u_getUnicodeProperties(c, binProps[which].column)&binProps[which].mask)!=0;
|
2002-11-30 04:41:53 +00:00
|
|
|
}
|
2002-03-06 23:31:11 +00:00
|
|
|
}
|
|
|
|
|
2002-07-04 00:17:12 +00:00
|
|
|
U_CAPI UBool U_EXPORT2
|
|
|
|
u_isUAlphabetic(UChar32 c) {
|
2002-03-06 23:31:11 +00:00
|
|
|
return u_hasBinaryProperty(c, UCHAR_ALPHABETIC);
|
|
|
|
}
|
|
|
|
|
2002-07-04 00:17:12 +00:00
|
|
|
U_CAPI UBool U_EXPORT2
|
|
|
|
u_isULowercase(UChar32 c) {
|
2002-03-06 23:31:11 +00:00
|
|
|
return u_hasBinaryProperty(c, UCHAR_LOWERCASE);
|
|
|
|
}
|
|
|
|
|
2002-07-04 00:17:12 +00:00
|
|
|
U_CAPI UBool U_EXPORT2
|
|
|
|
u_isUUppercase(UChar32 c) {
|
2002-03-06 23:31:11 +00:00
|
|
|
return u_hasBinaryProperty(c, UCHAR_UPPERCASE);
|
|
|
|
}
|
|
|
|
|
2002-07-04 00:17:12 +00:00
|
|
|
U_CAPI UBool U_EXPORT2
|
|
|
|
u_isUWhiteSpace(UChar32 c) {
|
2002-03-06 23:31:11 +00:00
|
|
|
return u_hasBinaryProperty(c, UCHAR_WHITE_SPACE);
|
|
|
|
}
|
2002-07-04 00:17:12 +00:00
|
|
|
|
2002-07-19 21:16:42 +00:00
|
|
|
U_CAPI UBool U_EXPORT2
|
|
|
|
uprv_isRuleWhiteSpace(UChar32 c) {
|
|
|
|
/* "white space" in the sense of ICU rule parsers: Cf+White_Space */
|
|
|
|
return
|
|
|
|
u_charType(c)==U_FORMAT_CHAR ||
|
|
|
|
u_hasBinaryProperty(c, UCHAR_WHITE_SPACE);
|
|
|
|
}
|
|
|
|
|
2002-11-07 01:28:14 +00:00
|
|
|
static const UChar _PATTERN[] = {
|
|
|
|
/* "[[:Cf:][:WSpace:]]" */
|
|
|
|
91, 91, 58, 67, 102, 58, 93, 91, 58, 87,
|
|
|
|
83, 112, 97, 99, 101, 58, 93, 93, 0
|
|
|
|
};
|
|
|
|
|
|
|
|
U_CAPI USet* U_EXPORT2
|
|
|
|
uprv_openRuleWhiteSpaceSet(UErrorCode* ec) {
|
|
|
|
return uset_openPattern(_PATTERN,
|
|
|
|
sizeof(_PATTERN)/sizeof(_PATTERN[0])-1, ec);
|
|
|
|
}
|
|
|
|
|
2002-07-04 00:17:12 +00:00
|
|
|
U_CAPI int32_t U_EXPORT2
|
|
|
|
u_getIntPropertyValue(UChar32 c, UProperty which) {
|
|
|
|
UErrorCode errorCode;
|
|
|
|
|
|
|
|
if(which<UCHAR_BINARY_START) {
|
|
|
|
return 0; /* undefined */
|
|
|
|
} else if(which<UCHAR_BINARY_LIMIT) {
|
|
|
|
return (int32_t)u_hasBinaryProperty(c, which);
|
|
|
|
} else if(which<UCHAR_INT_START) {
|
|
|
|
return 0; /* undefined */
|
|
|
|
} else if(which<UCHAR_INT_LIMIT) {
|
|
|
|
switch(which) {
|
|
|
|
case UCHAR_BIDI_CLASS:
|
|
|
|
return (int32_t)u_charDirection(c);
|
|
|
|
case UCHAR_BLOCK:
|
|
|
|
return (int32_t)ublock_getCode(c);
|
|
|
|
case UCHAR_CANONICAL_COMBINING_CLASS:
|
|
|
|
return u_getCombiningClass(c);
|
|
|
|
case UCHAR_DECOMPOSITION_TYPE:
|
2002-07-04 16:46:36 +00:00
|
|
|
return (int32_t)(u_getUnicodeProperties(c, 2)&UPROPS_DT_MASK);
|
2002-07-04 00:17:12 +00:00
|
|
|
case UCHAR_EAST_ASIAN_WIDTH:
|
2002-07-04 16:46:36 +00:00
|
|
|
return (int32_t)(u_getUnicodeProperties(c, 0)&UPROPS_EA_MASK)>>UPROPS_EA_SHIFT;
|
2002-07-04 00:17:12 +00:00
|
|
|
case UCHAR_GENERAL_CATEGORY:
|
|
|
|
return (int32_t)u_charType(c);
|
|
|
|
case UCHAR_JOINING_GROUP:
|
2002-07-04 16:46:36 +00:00
|
|
|
return (int32_t)(u_getUnicodeProperties(c, 2)&UPROPS_JG_MASK)>>UPROPS_JG_SHIFT;
|
2002-07-04 00:17:12 +00:00
|
|
|
case UCHAR_JOINING_TYPE:
|
2003-03-07 21:49:09 +00:00
|
|
|
return (int32_t)(u_getUnicodeProperties(c, 2)&UPROPS_JT_MASK)>>UPROPS_JT_SHIFT;
|
2002-07-04 00:17:12 +00:00
|
|
|
case UCHAR_LINE_BREAK:
|
2003-03-07 21:49:09 +00:00
|
|
|
return (int32_t)(u_getUnicodeProperties(c, 0)&UPROPS_LB_MASK)>>UPROPS_LB_SHIFT;
|
2002-07-04 00:17:12 +00:00
|
|
|
case UCHAR_NUMERIC_TYPE:
|
|
|
|
return (int32_t)GET_NUMERIC_TYPE(u_getUnicodeProperties(c, -1));
|
|
|
|
case UCHAR_SCRIPT:
|
|
|
|
errorCode=U_ZERO_ERROR;
|
|
|
|
return (int32_t)uscript_getScript(c, &errorCode);
|
|
|
|
default:
|
|
|
|
return 0; /* undefined */
|
|
|
|
}
|
2002-12-10 00:33:45 +00:00
|
|
|
} else if(which==UCHAR_GENERAL_CATEGORY_MASK) {
|
|
|
|
return U_MASK(u_charType(c));
|
2002-07-04 00:17:12 +00:00
|
|
|
} else {
|
|
|
|
return 0; /* undefined */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
U_CAPI int32_t U_EXPORT2
|
|
|
|
u_getIntPropertyMinValue(UProperty which) {
|
2003-03-04 00:52:07 +00:00
|
|
|
return 0; /* all binary/enum/int properties have a minimum value of 0 */
|
2002-07-04 00:17:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
U_CAPI int32_t U_EXPORT2
|
|
|
|
u_getIntPropertyMaxValue(UProperty which) {
|
2002-07-04 16:46:36 +00:00
|
|
|
int32_t max;
|
|
|
|
|
2002-07-04 00:17:12 +00:00
|
|
|
if(which<UCHAR_BINARY_START) {
|
2002-11-13 20:03:11 +00:00
|
|
|
return -1; /* undefined */
|
2002-07-04 00:17:12 +00:00
|
|
|
} else if(which<UCHAR_BINARY_LIMIT) {
|
|
|
|
return 1; /* maximum TRUE for all binary properties */
|
|
|
|
} else if(which<UCHAR_INT_START) {
|
2002-11-13 20:03:11 +00:00
|
|
|
return -1; /* undefined */
|
2002-07-04 00:17:12 +00:00
|
|
|
} else if(which<UCHAR_INT_LIMIT) {
|
|
|
|
switch(which) {
|
|
|
|
case UCHAR_BIDI_CLASS:
|
|
|
|
return (int32_t)U_CHAR_DIRECTION_COUNT-1;
|
|
|
|
case UCHAR_BLOCK:
|
2003-03-07 21:49:09 +00:00
|
|
|
max=(uprv_getMaxValues(0)&UPROPS_BLOCK_MASK)>>UPROPS_BLOCK_SHIFT;
|
|
|
|
return max!=0 ? max : (int32_t)UBLOCK_COUNT-1;
|
2002-07-04 00:17:12 +00:00
|
|
|
case UCHAR_CANONICAL_COMBINING_CLASS:
|
|
|
|
return 0xff; /* TODO do we need to be more precise, getting the actual maximum? */
|
|
|
|
case UCHAR_DECOMPOSITION_TYPE:
|
2003-03-07 21:49:09 +00:00
|
|
|
max=uprv_getMaxValues(0)&UPROPS_DT_MASK;
|
|
|
|
return max!=0 ? max : (int32_t)U_DT_COUNT-1;
|
2002-07-04 00:17:12 +00:00
|
|
|
case UCHAR_EAST_ASIAN_WIDTH:
|
2003-03-07 21:49:09 +00:00
|
|
|
max=(uprv_getMaxValues(0)&UPROPS_EA_MASK)>>UPROPS_EA_SHIFT;
|
|
|
|
return max!=0 ? max : (int32_t)U_EA_COUNT-1;
|
2002-07-04 00:17:12 +00:00
|
|
|
case UCHAR_GENERAL_CATEGORY:
|
|
|
|
return (int32_t)U_CHAR_CATEGORY_COUNT-1;
|
|
|
|
case UCHAR_JOINING_GROUP:
|
2003-03-07 21:49:09 +00:00
|
|
|
max=(uprv_getMaxValues(0)&UPROPS_JG_MASK)>>UPROPS_JG_SHIFT;
|
|
|
|
return max!=0 ? max : (int32_t)U_JG_COUNT-1;
|
2002-07-04 00:17:12 +00:00
|
|
|
case UCHAR_JOINING_TYPE:
|
2003-03-07 21:49:09 +00:00
|
|
|
max=(uprv_getMaxValues(0)&UPROPS_JT_MASK)>>UPROPS_JT_SHIFT;
|
|
|
|
return max!=0 ? max : (int32_t)U_JT_COUNT-1;
|
2002-07-04 00:17:12 +00:00
|
|
|
case UCHAR_LINE_BREAK:
|
2003-03-07 21:49:09 +00:00
|
|
|
max=(uprv_getMaxValues(0)&UPROPS_LB_MASK)>>UPROPS_LB_SHIFT;
|
|
|
|
return max!=0 ? max : (int32_t)U_LB_COUNT-1;
|
2002-07-04 00:17:12 +00:00
|
|
|
case UCHAR_NUMERIC_TYPE:
|
|
|
|
return (int32_t)U_NT_COUNT-1;
|
|
|
|
case UCHAR_SCRIPT:
|
2003-03-07 21:49:09 +00:00
|
|
|
max=uprv_getMaxValues(0)&UPROPS_SCRIPT_MASK;
|
|
|
|
return max!=0 ? max : (int32_t)USCRIPT_CODE_LIMIT-1;
|
2002-07-04 00:17:12 +00:00
|
|
|
default:
|
2002-11-13 20:03:11 +00:00
|
|
|
return -1; /* undefined */
|
2002-07-04 00:17:12 +00:00
|
|
|
}
|
|
|
|
} else {
|
2002-11-13 20:03:11 +00:00
|
|
|
return -1; /* undefined */
|
2002-07-04 00:17:12 +00:00
|
|
|
}
|
|
|
|
}
|
2002-10-30 18:12:49 +00:00
|
|
|
|
|
|
|
/*----------------------------------------------------------------
|
|
|
|
* Inclusions list
|
2002-11-12 00:43:02 +00:00
|
|
|
*----------------------------------------------------------------*/
|
2002-10-30 18:12:49 +00:00
|
|
|
|
2002-11-06 00:52:44 +00:00
|
|
|
/*
|
|
|
|
* Return a set of characters for property enumeration.
|
2002-11-25 22:42:55 +00:00
|
|
|
* The set implicitly contains 0x110000 as well, which is one more than the highest
|
|
|
|
* Unicode code point.
|
|
|
|
*
|
|
|
|
* This set is used as an ordered list - its code points are ordered, and
|
|
|
|
* consecutive code points (in Unicode code point order) in the set define a range.
|
2002-11-06 00:52:44 +00:00
|
|
|
* For each two consecutive characters (start, limit) in the set,
|
2002-11-25 22:42:55 +00:00
|
|
|
* all of the UCD/normalization and related properties for
|
|
|
|
* all code points start..limit-1 are all the same,
|
|
|
|
* except for character names and ISO comments.
|
|
|
|
*
|
|
|
|
* All Unicode code points U+0000..U+10ffff are covered by these ranges.
|
|
|
|
* The ranges define a partition of the Unicode code space.
|
|
|
|
* ICU uses the inclusions set to enumerate properties for generating
|
|
|
|
* UnicodeSets containing all code points that have a certain property value.
|
2002-10-30 18:12:49 +00:00
|
|
|
*
|
2002-11-06 00:52:44 +00:00
|
|
|
* The Inclusion List is generated from the UCD. It is generated
|
|
|
|
* by enumerating the data tries, and code points for hardcoded properties
|
|
|
|
* are added as well.
|
2002-10-30 18:12:49 +00:00
|
|
|
*
|
2002-11-25 22:42:55 +00:00
|
|
|
* --------------------------------------------------------------------------
|
|
|
|
*
|
2002-11-06 00:52:44 +00:00
|
|
|
* The following are ideas for getting properties-unique code point ranges,
|
|
|
|
* with possible optimizations beyond the current implementation.
|
|
|
|
* These optimizations would require more code and be more fragile.
|
|
|
|
* The current implementation generates one single list (set) for all properties.
|
2002-10-30 18:12:49 +00:00
|
|
|
*
|
|
|
|
* To enumerate properties efficiently, one needs to know ranges of
|
|
|
|
* repetitive values, so that the value of only each start code point
|
|
|
|
* can be applied to the whole range.
|
2002-11-06 00:52:44 +00:00
|
|
|
* This information is in principle available in the uprops.icu/unorm.icu data.
|
2002-10-30 18:12:49 +00:00
|
|
|
*
|
|
|
|
* There are two obstacles:
|
|
|
|
*
|
|
|
|
* 1. Some properties are computed from multiple data structures,
|
|
|
|
* making it necessary to get repetitive ranges by intersecting
|
|
|
|
* ranges from multiple tries.
|
|
|
|
*
|
|
|
|
* 2. It is not economical to write code for getting repetitive ranges
|
|
|
|
* that are precise for each of some 50 properties.
|
|
|
|
*
|
|
|
|
* Compromise ideas:
|
|
|
|
*
|
|
|
|
* - Get ranges per trie, not per individual property.
|
|
|
|
* Each range contains the same values for a whole group of properties.
|
|
|
|
* This would generate currently five range sets, two for uprops.icu tries
|
|
|
|
* and three for unorm.icu tries.
|
|
|
|
*
|
|
|
|
* - Combine sets of ranges for multiple tries to get sufficient sets
|
|
|
|
* for properties, e.g., the uprops.icu main and auxiliary tries
|
|
|
|
* for all non-normalization properties.
|
|
|
|
*
|
|
|
|
* Ideas for representing ranges and combining them:
|
|
|
|
*
|
|
|
|
* - A UnicodeSet could hold just the start code points of ranges.
|
|
|
|
* Multiple sets are easily combined by or-ing them together.
|
|
|
|
*
|
|
|
|
* - Alternatively, a UnicodeSet could hold each even-numbered range.
|
|
|
|
* All ranges could be enumerated by using each start code point
|
|
|
|
* (for the even-numbered ranges) as well as each limit (end+1) code point
|
|
|
|
* (for the odd-numbered ranges).
|
|
|
|
* It should be possible to combine two such sets by xor-ing them,
|
|
|
|
* but no more than two.
|
|
|
|
*
|
|
|
|
* The second way to represent ranges may(?!) yield smaller UnicodeSet arrays,
|
|
|
|
* but the first one is certainly simpler and applicable for combining more than
|
|
|
|
* two range sets.
|
|
|
|
*
|
|
|
|
* It is possible to combine all range sets for all uprops/unorm tries into one
|
|
|
|
* set that can be used for all properties.
|
|
|
|
* As an optimization, there could be less-combined range sets for certain
|
|
|
|
* groups of properties.
|
|
|
|
* The relationship of which less-combined range set to use for which property
|
|
|
|
* depends on the implementation of the properties and must be hardcoded
|
|
|
|
* - somewhat error-prone and higher maintenance but can be tested easily
|
|
|
|
* by building property sets "the simple way" in test code.
|
|
|
|
*
|
|
|
|
* ---
|
|
|
|
*
|
|
|
|
* Do not use a UnicodeSet pattern because that causes infinite recursion;
|
|
|
|
* UnicodeSet depends on the inclusions set.
|
|
|
|
*/
|
|
|
|
U_CAPI void U_EXPORT2
|
|
|
|
uprv_getInclusions(USet* set) {
|
2002-11-06 00:52:44 +00:00
|
|
|
uset_removeRange(set, 0, 0x10ffff);
|
2002-10-30 18:12:49 +00:00
|
|
|
|
2002-11-06 00:52:44 +00:00
|
|
|
unorm_addPropertyStarts(set);
|
|
|
|
uchar_addPropertyStarts(set);
|
2002-10-30 18:12:49 +00:00
|
|
|
}
|