From 0b5b91a70b3eb8c9242e35fc211870035efac4d5 Mon Sep 17 00:00:00 2001 From: Peter Edberg Date: Thu, 5 Oct 2017 20:36:07 +0000 Subject: [PATCH] ICU-13366 Changes per Shane codereview comments X-SVN-Rev: 40572 --- icu4c/source/i18n/smpdtfmt.cpp | 4 +--- icu4c/source/i18n/tzfmt.cpp | 3 --- icu4c/source/i18n/tzgnames.cpp | 2 -- icu4c/source/i18n/tznames_impl.cpp | 7 +++---- icu4c/source/i18n/tznames_impl.h | 3 +++ .../core/src/com/ibm/icu/text/SimpleDateFormat.java | 5 ++--- 6 files changed, 9 insertions(+), 15 deletions(-) diff --git a/icu4c/source/i18n/smpdtfmt.cpp b/icu4c/source/i18n/smpdtfmt.cpp index cc9e9d3f0e..c4d325cc48 100644 --- a/icu4c/source/i18n/smpdtfmt.cpp +++ b/icu4c/source/i18n/smpdtfmt.cpp @@ -71,6 +71,7 @@ #include "uvector.h" #include "cstr.h" #include "dayperiodrules.h" +#include "tznames_impl.h" // ZONE_NAME_U16_MAX #if defined( U_DEBUG_CALSVC ) || defined (U_DEBUG_CAL) #include @@ -80,9 +81,6 @@ // class SimpleDateFormat // ***************************************************************************** -// Some zone display names involving supplementary characters can be over 50 chars, 100 UTF-16 code units, 200 UTF-8 bytes -#define ZONE_NAME_U16_MAX 128 - U_NAMESPACE_BEGIN /** diff --git a/icu4c/source/i18n/tzfmt.cpp b/icu4c/source/i18n/tzfmt.cpp index f31db10d2a..9e8f6081bc 100644 --- a/icu4c/source/i18n/tzfmt.cpp +++ b/icu4c/source/i18n/tzfmt.cpp @@ -33,9 +33,6 @@ #include "tznames_impl.h" // TextTrieMap #include "patternprops.h" -// Some zone display names involving supplementary characters can be over 50 chars, 100 UTF-16 code units, 200 UTF-8 bytes -#define ZONE_NAME_U16_MAX 128 - U_NAMESPACE_BEGIN // Bit flags used by the parse method. diff --git a/icu4c/source/i18n/tzgnames.cpp b/icu4c/source/i18n/tzgnames.cpp index a8b036c413..c2e685272e 100644 --- a/icu4c/source/i18n/tzgnames.cpp +++ b/icu4c/source/i18n/tzgnames.cpp @@ -37,8 +37,6 @@ U_NAMESPACE_BEGIN #define ZID_KEY_MAX 128 -// Some zone display names involving supplementary characters can be over 50 chars, 100 UTF-16 code units, 200 UTF-8 bytes -#define ZONE_NAME_U16_MAX 128 static const char gZoneStrings[] = "zoneStrings"; diff --git a/icu4c/source/i18n/tznames_impl.cpp b/icu4c/source/i18n/tznames_impl.cpp index 080a7763b2..7045f09951 100644 --- a/icu4c/source/i18n/tznames_impl.cpp +++ b/icu4c/source/i18n/tznames_impl.cpp @@ -18,6 +18,7 @@ #include "unicode/strenum.h" #include "unicode/ustring.h" #include "unicode/timezone.h" +#include "unicode/utf16.h" #include "tznames_impl.h" #include "cmemory.h" @@ -415,10 +416,8 @@ TextTrieMap::search(CharacterNode *node, const UnicodeString &text, int32_t star // for folding we need to get a complete code point. // size of character may grow after fold operation; // then we need to get result as UTF16 code units. - UChar32 c32 = text.char32At(index++); - if (c32 >= 0x10000) { - index++; - } + UChar32 c32 = text.char32At(index); + index += U16_LENGTH(c32); UnicodeString tmp(c32); tmp.foldCase(); int32_t tmpidx = 0; diff --git a/icu4c/source/i18n/tznames_impl.h b/icu4c/source/i18n/tznames_impl.h index 0aac1de554..4db036e747 100644 --- a/icu4c/source/i18n/tznames_impl.h +++ b/icu4c/source/i18n/tznames_impl.h @@ -27,6 +27,9 @@ #include "uvector.h" #include "umutex.h" +// Some zone display names involving supplementary characters can be over 50 chars, 100 UTF-16 code units, 200 UTF-8 bytes +#define ZONE_NAME_U16_MAX 128 + U_NAMESPACE_BEGIN /* diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/SimpleDateFormat.java b/icu4j/main/classes/core/src/com/ibm/icu/text/SimpleDateFormat.java index 5c81eba1e1..ab7511ee16 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/text/SimpleDateFormat.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/text/SimpleDateFormat.java @@ -1156,7 +1156,7 @@ public class SimpleDateFormat extends DateFormat { String digits = null; if (numberFormat instanceof DecimalFormat) { DecimalFormatSymbols decsym = ((DecimalFormat) numberFormat).getDecimalFormatSymbols(); - String[] strDigits = decsym.getDigitStrings(); + String[] strDigits = decsym.getDigitStringsLocal(); // Note: TimeZoneFormat#setGMTOffsetDigits() does not support string array, // so we need to concatenate digits to make a single string. StringBuilder digitsBuf = new StringBuilder(); @@ -3247,8 +3247,7 @@ public class SimpleDateFormat extends DateFormat { /* Skip this for Chinese calendar, moved from ChineseDateFormat */ if ( override != null && (override.compareTo("hebr") == 0 || override.indexOf("y=hebr") >= 0) && value < 1000 ) { value += HEBREW_CAL_CUR_MILLENIUM_START_YEAR; - } else if (count == 2 && text.codePointCount(start, pos.getIndex()) == 2 && cal.haveDefaultCentury() - && countDigits(text, start, pos.getIndex()) == 2) { + } else if (count == 2 && countDigits(text, start, pos.getIndex()) == 2 && cal.haveDefaultCentury()) { // Assume for example that the defaultCenturyStart is 6/18/1903. // This means that two-digit years will be forced into the range // 6/18/1903 to 6/17/2003. As a result, years 00, 01, and 02