]> granicus.if.org Git - icu/commitdiff
ICU-13366 Changes per Shane codereview comments
authorPeter Edberg <pedberg@unicode.org>
Thu, 5 Oct 2017 20:36:07 +0000 (20:36 +0000)
committerPeter Edberg <pedberg@unicode.org>
Thu, 5 Oct 2017 20:36:07 +0000 (20:36 +0000)
X-SVN-Rev: 40572

icu4c/source/i18n/smpdtfmt.cpp
icu4c/source/i18n/tzfmt.cpp
icu4c/source/i18n/tzgnames.cpp
icu4c/source/i18n/tznames_impl.cpp
icu4c/source/i18n/tznames_impl.h
icu4j/main/classes/core/src/com/ibm/icu/text/SimpleDateFormat.java

index cc9e9d3f0e476e63211f7a47a68c5591c04ea47d..c4d325cc485b941cb548e92267c78266c39a3532 100644 (file)
@@ -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 <stdio.h>
@@ -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
 
 /**
index f31db10d2ab907b7cebbbca215486d46dd72c29c..9e8f6081bc9b1a6e53cb4e66222f323fe797f7ca 100644 (file)
@@ -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.
index a8b036c41342aa337ecdad9c4086f20e4f19de62..c2e685272e9b36713dcee19462d3f31220371faf 100644 (file)
@@ -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";
 
index 080a7763b2bf180cf61b686e40ac96ccd7e73d50..7045f099516e512f4e35587a978fd75e28824f93 100644 (file)
@@ -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;
index 0aac1de5545802155037ae9677342bcde916847f..4db036e7475e3568d670d1b9554979f4848d7b5c 100644 (file)
@@ -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
 
 /*
index 5c81eba1e1fde3971707ab27b96e729026a0151e..ab7511ee160729af4c87087e5b68a83e726fe4c4 100644 (file)
@@ -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