]> granicus.if.org Git - icu/commitdiff
ICU-10161 trimMarksFromAffix must trim all marks; update "ar" number patterns to...
authorPeter Edberg <pedberg@unicode.org>
Thu, 5 Sep 2013 22:13:07 +0000 (22:13 +0000)
committerPeter Edberg <pedberg@unicode.org>
Thu, 5 Sep 2013 22:13:07 +0000 (22:13 +0000)
X-SVN-Rev: 34203

icu4c/source/data/locales/ar.txt
icu4c/source/i18n/decimfmt.cpp
icu4c/source/test/intltest/numfmtst.cpp

index 4b88cbd349cbd70454229d874a65a32abc012ba0..2860e547bd5a7b3ff968b4eb9222eda05c435d70 100644 (file)
@@ -23,8 +23,8 @@ ar{
     NumberElements{
         arab{
             patterns{
-                currencyFormat{"¤ #0.00;¤ #0.00-"}
-                decimalFormat{"#0.###"}
+                currencyFormat{"¤ #,##0.00"}
+                decimalFormat{"#,##0.###"}
                 percentFormat{"#,##0%"}
                 scientificFormat{"#E0"}
             }
@@ -44,7 +44,7 @@ ar{
         default{"arab"}
         latn{
             patterns{
-                currencyFormat{"¤ #,##0.00;¤ #,##0.00-"}
+                currencyFormat{"¤ #,##0.00"}
                 decimalFormat{"#,##0.###"}
                 percentFormat{"#,##0%"}
                 scientificFormat{"#E0"}
index 13e3073f9edfcaddb871d7557e4d84eed5c1e49c..72b2e76cb726b43ff1cfffe8051bdd94ce5f7833 100644 (file)
@@ -2904,23 +2904,24 @@ static UBool equalWithSignCompatibility(UChar32 lhs, UChar32 rhs) {
 // check for LRM 0x200E, RLM 0x200F, ALM 0x061C
 #define IS_BIDI_MARK(c) (c==0x200E || c==0x200F || c==0x061C)
 
-// The following assumes any marks are at the beginning or end of the affix
+#define TRIM_BUFLEN 32
 UnicodeString& DecimalFormat::trimMarksFromAffix(const UnicodeString& affix, UnicodeString& trimmedAffix) {
-    int32_t first = 0;
-    int32_t last = affix.length() - 1;
-    if (last > 0) {
-        UChar c = affix.charAt(0);
-        if (IS_BIDI_MARK(c)) {
-            first++;
-        }
-        if (last > first) {
-            c = affix.charAt(last);
-            if (IS_BIDI_MARK(c)) {
-                last--;
-            }
+    UChar trimBuf[TRIM_BUFLEN];
+    int32_t affixLen = affix.length();
+    int32_t affixPos, trimLen = 0;
+    
+    for (affixPos = 0; affixPos < affixLen; affixPos++) {
+        UChar c = affix.charAt(affixPos);
+        if (!IS_BIDI_MARK(c)) {
+               if (trimLen < TRIM_BUFLEN) {
+                       trimBuf[trimLen++] = c;
+               } else {
+                       trimLen = 0;
+                       break;
+               }
         }
     }
-    return trimmedAffix.setTo(affix, first, last + 1 - first);
+    return (trimLen > 0)? trimmedAffix.setTo(trimBuf, trimLen): trimmedAffix.setTo(affix);
 }
 
 /**
@@ -2939,6 +2940,8 @@ int32_t DecimalFormat::compareSimpleAffix(const UnicodeString& affix,
                                           UBool lenient) {
     int32_t start = pos;
     UnicodeString trimmedAffix;
+    // For more efficiency we should keep lazily-created trimmed affixes around in
+    // instance variables instead of trimming each time they are used (the next step)
     trimMarksFromAffix(affix, trimmedAffix);
     UChar32 affixChar = trimmedAffix.char32At(0);
     int32_t affixLength = trimmedAffix.length();
index 9dbced328fe972a528c0f49ba33790beccae004f..4eb1aa7ceb4d1cfcbc95563242277b559efaf56d 100644 (file)
@@ -3092,7 +3092,7 @@ void NumberFormatTest::TestNumberingSystems() {
         { "en_US@numbers=thai", 1234.567, FALSE, "\\u0E51,\\u0E52\\u0E53\\u0E54.\\u0E55\\u0E56\\u0E57" },
         { "en_US@numbers=hebr", 5678.0, TRUE, "\\u05D4\\u05F3\\u05EA\\u05E8\\u05E2\\u05F4\\u05D7" },
         { "en_US@numbers=arabext", 1234.567, FALSE, "\\u06F1\\u066c\\u06F2\\u06F3\\u06F4\\u066b\\u06F5\\u06F6\\u06F7" },
-        { "ar_EG", 1234.567, FALSE, "\\u0661\\u0662\\u0663\\u0664\\u066b\\u0665\\u0666\\u0667" },
+        { "ar_EG", 1234.567, FALSE, "\\u0661\\u066C\\u0662\\u0663\\u0664\\u066b\\u0665\\u0666\\u0667" },
         { "th_TH@numbers=traditional", 1234.567, FALSE, "\\u0E51,\\u0E52\\u0E53\\u0E54.\\u0E55\\u0E56\\u0E57" }, // fall back to native per TR35
         { "ar_MA", 1234.567, FALSE, "1.234,567" },
         { "en_US@numbers=hanidec", 1234.567, FALSE, "\\u4e00,\\u4e8c\\u4e09\\u56db.\\u4e94\\u516d\\u4e03" },