From b0ad84012f6a40dcf960d7b6e50af3c5c9f7864d Mon Sep 17 00:00:00 2001 From: Markus Scherer Date: Thu, 27 Apr 2017 18:29:07 +0000 Subject: [PATCH] ICU-12985 implement the binary Regional_Indicator property with a single hardcoded range X-SVN-Rev: 40083 --- icu4c/source/common/unicode/uchar.h | 5 +++++ icu4c/source/common/uprops.cpp | 6 ++++++ icu4c/source/test/cintltst/cucdtst.c | 7 +++++++ .../core/src/com/ibm/icu/impl/UCharacterProperty.java | 7 +++++++ .../classes/core/src/com/ibm/icu/lang/UProperty.java | 8 +++++++- .../src/com/ibm/icu/dev/test/lang/UCharacterTest.java | 9 +++++++++ 6 files changed, 41 insertions(+), 1 deletion(-) diff --git a/icu4c/source/common/unicode/uchar.h b/icu4c/source/common/unicode/uchar.h index c10884103b6..787b189b82f 100644 --- a/icu4c/source/common/unicode/uchar.h +++ b/icu4c/source/common/unicode/uchar.h @@ -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. diff --git a/icu4c/source/common/uprops.cpp b/icu4c/source/common/uprops.cpp index 486ce17edc9..7f1e64511b9 100644 --- a/icu4c/source/common/uprops.cpp +++ b/icu4c/source/common/uprops.cpp @@ -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 diff --git a/icu4c/source/test/cintltst/cucdtst.c b/icu4c/source/test/cintltst/cucdtst.c index 2b3230bc900..8966dcf5fc9 100644 --- a/icu4c/source/test/cintltst/cucdtst.c +++ b/icu4c/source/test/cintltst/cucdtst.c @@ -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 } diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/UCharacterProperty.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/UCharacterProperty.java index 33aa7f1b6cd..041e59a0ca0 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/impl/UCharacterProperty.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/UCharacterProperty.java @@ -405,6 +405,13 @@ public final class UCharacterProperty new BinaryProperty(2, 1<