ICU-12985 implement the binary Regional_Indicator property with a single hardcoded range
X-SVN-Rev: 40083
This commit is contained in:
parent
6ce7f348a3
commit
b0ad84012f
@ -434,6 +434,11 @@ typedef enum UProperty {
|
||||
* @stable ICU 60
|
||||
*/
|
||||
UCHAR_EMOJI_COMPONENT=61,
|
||||
/**
|
||||
* Binary property Regional_Indicator.
|
||||
* @stable ICU 60
|
||||
*/
|
||||
UCHAR_REGIONAL_INDICATOR=62,
|
||||
#ifndef U_HIDE_DEPRECATED_API
|
||||
/**
|
||||
* One more than the last constant for binary Unicode properties.
|
||||
|
@ -206,6 +206,11 @@ static UBool isPOSIX_xdigit(const BinaryProperty &/*prop*/, UChar32 c, UProperty
|
||||
return u_isxdigit(c);
|
||||
}
|
||||
|
||||
static UBool isRegionalIndicator(const BinaryProperty &/*prop*/, UChar32 c, UProperty /*which*/) {
|
||||
// Property starts are a subset of lb=RI etc.
|
||||
return 0x1F1E6<=c && c<=0x1F1FF;
|
||||
}
|
||||
|
||||
static const BinaryProperty binProps[UCHAR_BINARY_LIMIT]={
|
||||
/*
|
||||
* column and mask values for binary properties from u_getUnicodeProperties().
|
||||
@ -277,6 +282,7 @@ static const BinaryProperty binProps[UCHAR_BINARY_LIMIT]={
|
||||
{ 2, U_MASK(UPROPS_2_EMOJI_MODIFIER), defaultContains },
|
||||
{ 2, U_MASK(UPROPS_2_EMOJI_MODIFIER_BASE), defaultContains },
|
||||
{ 2, U_MASK(UPROPS_2_EMOJI_COMPONENT), defaultContains },
|
||||
{ 2, 0, isRegionalIndicator },
|
||||
};
|
||||
|
||||
U_CAPI UBool U_EXPORT2
|
||||
|
@ -2674,6 +2674,13 @@ TestAdditionalProperties() {
|
||||
{ 0x10AEF, UCHAR_JOINING_GROUP, U_JG_MANICHAEAN_HUNDRED },
|
||||
{ 0x10AF0, UCHAR_JOINING_GROUP, U_JG_NO_JOINING_GROUP },
|
||||
|
||||
{ -1, 0xa00, 0 }, // version break for Unicode 10
|
||||
|
||||
{ 0x1F1E5, UCHAR_REGIONAL_INDICATOR, FALSE },
|
||||
{ 0x1F1E7, UCHAR_REGIONAL_INDICATOR, TRUE },
|
||||
{ 0x1F1FF, UCHAR_REGIONAL_INDICATOR, TRUE },
|
||||
{ 0x1F200, UCHAR_REGIONAL_INDICATOR, FALSE },
|
||||
|
||||
/* undefined UProperty values */
|
||||
{ 0x61, 0x4a7, 0 },
|
||||
{ 0x234bc, 0x15ed, 0 }
|
||||
|
@ -405,6 +405,13 @@ public final class UCharacterProperty
|
||||
new BinaryProperty(2, 1<<PROPS_2_EMOJI_MODIFIER),
|
||||
new BinaryProperty(2, 1<<PROPS_2_EMOJI_MODIFIER_BASE),
|
||||
new BinaryProperty(2, 1<<PROPS_2_EMOJI_COMPONENT),
|
||||
new BinaryProperty(SRC_PROPSVEC) { // REGIONAL_INDICATOR
|
||||
// Property starts are a subset of lb=RI etc.
|
||||
@Override
|
||||
boolean contains(int c) {
|
||||
return 0x1F1E6<=c && c<=0x1F1FF;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
public boolean hasBinaryProperty(int c, int which) {
|
||||
|
@ -549,13 +549,19 @@ public interface UProperty
|
||||
* @stable ICU 60
|
||||
*/
|
||||
public static final int EMOJI_COMPONENT=61;
|
||||
/**
|
||||
* Binary property Regional_Indicator.
|
||||
*
|
||||
* @stable ICU 60
|
||||
*/
|
||||
public static final int REGIONAL_INDICATOR=62;
|
||||
|
||||
/**
|
||||
* One more than the last constant for binary Unicode properties.
|
||||
* @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final int BINARY_LIMIT = 62;
|
||||
public static final int BINARY_LIMIT = 63;
|
||||
|
||||
/**
|
||||
* Enumerated property Bidi_Class.
|
||||
|
@ -1719,6 +1719,8 @@ public final class UCharacterTest extends TestFmwk
|
||||
@Test
|
||||
public void TestAdditionalProperties()
|
||||
{
|
||||
final int FALSE = 0;
|
||||
final int TRUE = 1;
|
||||
// test data for hasBinaryProperty()
|
||||
int props[][] = { // code point, property
|
||||
{ 0x0627, UProperty.ALPHABETIC, 1 },
|
||||
@ -2134,6 +2136,13 @@ public final class UCharacterTest extends TestFmwk
|
||||
{ 0x10AEF, UProperty.JOINING_GROUP, UCharacter.JoiningGroup.MANICHAEAN_HUNDRED },
|
||||
{ 0x10AF0, UProperty.JOINING_GROUP, UCharacter.JoiningGroup.NO_JOINING_GROUP },
|
||||
|
||||
{ -1, 0xa00, 0 }, // version break for Unicode 10
|
||||
|
||||
{ 0x1F1E5, UProperty.REGIONAL_INDICATOR, FALSE },
|
||||
{ 0x1F1E7, UProperty.REGIONAL_INDICATOR, TRUE },
|
||||
{ 0x1F1FF, UProperty.REGIONAL_INDICATOR, TRUE },
|
||||
{ 0x1F200, UProperty.REGIONAL_INDICATOR, FALSE },
|
||||
|
||||
/* undefined UProperty values */
|
||||
{ 0x61, 0x4a7, 0 },
|
||||
{ 0x234bc, 0x15ed, 0 }
|
||||
|
Loading…
Reference in New Issue
Block a user