]> granicus.if.org Git - icu/commitdiff
ICU-21344 Fix wrong passing of script in Locale.
authorFrank Tang <ftang@chromium.org>
Wed, 21 Oct 2020 21:11:40 +0000 (14:11 -0700)
committerFrank Yung-Fong Tang <ftang@google.com>
Wed, 21 Oct 2020 23:46:01 +0000 (16:46 -0700)
Also add same unit test in Java which have no problem.

icu4c/source/common/locid.cpp
icu4c/source/test/intltest/loctest.cpp
icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ULocaleTest.java

index 2804e36bf62cb1465eb25b666dc3b71a28d2aab0..cc25414b09cdb0bcffa597aa7f4ca32fc0cbdc5f 100644 (file)
@@ -35,6 +35,7 @@
 
 #include "unicode/bytestream.h"
 #include "unicode/locid.h"
+#include "unicode/localebuilder.h"
 #include "unicode/strenum.h"
 #include "unicode/stringpiece.h"
 #include "unicode/uloc.h"
@@ -1336,7 +1337,10 @@ AliasReplacer::replaceTerritory(UVector& toBeFreed, UErrorCode& status)
         // Cannot use nullptr for language because that will construct
         // the default locale, in that case, use "und" to get the correct
         // locale.
-        Locale l(language == nullptr ? "und" : language, nullptr, script);
+        Locale l = LocaleBuilder()
+            .setLanguage(language == nullptr ? "und" : language)
+            .setScript(script)
+            .build(status);
         l.addLikelySubtags(status);
         const char* likelyRegion = l.getCountry();
         CharString* item = nullptr;
index b80711951a21b670f9af777d91ce8d879a94f821..a847a957d98a65091b9121abb4ba2b212d94f355 100644 (file)
@@ -4894,6 +4894,9 @@ void LocaleTest::TestCanonicalize(void)
         { "ja-Latn-hepburn-heploc", "ja-Latn-alalc97"},
 
         { "aaa-Fooo-SU", "aaa-Fooo-RU"},
+
+        // ICU-21344
+        { "ku-Arab-NT", "ku-Arab-IQ"},
     };
     int32_t i;
     for (i=0; i < UPRV_LENGTHOF(testCases); i++) {
index bfa04d6ff112f0c8d52d0cf503e16e99dae2f766..40bcb0e4b264e93f2f177a754a01da968e971763 100644 (file)
@@ -5212,6 +5212,9 @@ public class ULocaleTest extends TestFmwk {
         Assert.assertEquals("ja-Latn-alalc97", canonicalTag("ja-Latn-hepburn-heploc"));
 
         Assert.assertEquals("aaa-Fooo-RU", canonicalTag("aaa-Fooo-SU"));
+
+        // ICU-21344
+        Assert.assertEquals("ku-Arab-IQ", canonicalTag("ku-Arab-NT"));
     }
 
     @Test