Title: [262992] trunk
Revision
262992
Author
ysuz...@apple.com
Date
2020-06-12 18:15:20 -0700 (Fri, 12 Jun 2020)

Log Message

[JSC] el(Greek) characters' upper-case conversion is locale-sensitive
https://bugs.webkit.org/show_bug.cgi?id=213155
<rdar://problem/55018467>

Reviewed by Darin Adler.

JSTests:

* stress/intl-el-case.js: Added.
(shouldBe):

Source/_javascript_Core:

CLDR defines 4 locales which has language-sensitive case conversions. "az", "el", "lt", and "tr", where,

    az = Azerbaijani
    el = Greek
    lt = Lithuanian
    tr = Turkish

We can ensure it easily like this.

    1. Download CLDR data
    2. `ls common/transforms/*Upper.xml`

        common/transforms/az-Upper.xml
        common/transforms/el-Upper.xml
        common/transforms/lt-Upper.xml
        common/transforms/tr-Upper.xml

And ECMA-402 String.prototype.{toLocaleLowerCase,toLocaleUpperCase} requires these locales are listed as `availableLocales`.

    > 7. Let availableLocales be a List with language tags that includes the languages for which the Unicode Character
    >    Database contains language sensitive case mappings. Implementations may add additional language tags if they
    >    support case mapping for additional locales.

    https://tc39.es/ecma402/#sup-string.prototype.tolocalelowercase

This patch adds "el" to our maintained availableLocales list. Previously we only had "az", "lt", and "tr".

* runtime/StringPrototype.cpp:
(JSC::toLocaleCase):
(JSC::stringProtoFuncToLocaleUpperCase):

Modified Paths

Added Paths

Diff

Modified: trunk/JSTests/ChangeLog (262991 => 262992)


--- trunk/JSTests/ChangeLog	2020-06-13 00:22:31 UTC (rev 262991)
+++ trunk/JSTests/ChangeLog	2020-06-13 01:15:20 UTC (rev 262992)
@@ -1,3 +1,14 @@
+2020-06-12  Yusuke Suzuki  <ysuz...@apple.com>
+
+        [JSC] el(Greek) characters' upper-case conversion is locale-sensitive
+        https://bugs.webkit.org/show_bug.cgi?id=213155
+        <rdar://problem/55018467>
+
+        Reviewed by Darin Adler.
+
+        * stress/intl-el-case.js: Added.
+        (shouldBe):
+
 2020-06-12  Keith Miller  <keith_mil...@apple.com>
 
         Tests expecting a crash should use a signal handler in the JSC CLI process

Added: trunk/JSTests/stress/intl-el-case.js (0 => 262992)


--- trunk/JSTests/stress/intl-el-case.js	                        (rev 0)
+++ trunk/JSTests/stress/intl-el-case.js	2020-06-13 01:15:20 UTC (rev 262992)
@@ -0,0 +1,18 @@
+function shouldBe(actual, expected) {
+    if (actual !== expected)
+        print(`expected ${expected} but got ${actual}`);
+}
+
+// "Coming Soon" in Greek.
+shouldBe(`Σύντομα διαθέσιμο`.toLocaleUpperCase('en-US'), `ΣΎΝΤΟΜΑ ΔΙΑΘΈΣΙΜΟ`);
+shouldBe(`Σύντομα διαθέσιμο`.toLocaleUpperCase('el'), `ΣΥΝΤΟΜΑ ΔΙΑΘΕΣΙΜΟ`);
+shouldBe(`Σύντομα διαθέσιμο`.toLocaleUpperCase('el-gr'), `ΣΥΝΤΟΜΑ ΔΙΑΘΕΣΙΜΟ`);
+
+// Sigma handling is not locale-sensitive but included in this test.
+shouldBe(`AAAΣ`.toLocaleLowerCase('en-US'), `aaaς`);
+shouldBe(`AAAΣ`.toLocaleLowerCase('el'), `aaaς`);
+shouldBe(`AAAΣ`.toLocaleLowerCase('el-gr'), `aaaς`);
+
+shouldBe(`ΣAAA`.toLocaleLowerCase('en-US'), `σaaa`);
+shouldBe(`ΣAAA`.toLocaleLowerCase('el'), `σaaa`);
+shouldBe(`ΣAAA`.toLocaleLowerCase('el-gr'), `σaaa`);

Modified: trunk/Source/_javascript_Core/ChangeLog (262991 => 262992)


--- trunk/Source/_javascript_Core/ChangeLog	2020-06-13 00:22:31 UTC (rev 262991)
+++ trunk/Source/_javascript_Core/ChangeLog	2020-06-13 01:15:20 UTC (rev 262992)
@@ -1,3 +1,42 @@
+2020-06-12  Yusuke Suzuki  <ysuz...@apple.com>
+
+        [JSC] el(Greek) characters' upper-case conversion is locale-sensitive
+        https://bugs.webkit.org/show_bug.cgi?id=213155
+        <rdar://problem/55018467>
+
+        Reviewed by Darin Adler.
+
+        CLDR defines 4 locales which has language-sensitive case conversions. "az", "el", "lt", and "tr", where,
+
+            az = Azerbaijani
+            el = Greek
+            lt = Lithuanian
+            tr = Turkish
+
+        We can ensure it easily like this.
+
+            1. Download CLDR data
+            2. `ls common/transforms/*Upper.xml`
+
+                common/transforms/az-Upper.xml
+                common/transforms/el-Upper.xml
+                common/transforms/lt-Upper.xml
+                common/transforms/tr-Upper.xml
+
+        And ECMA-402 String.prototype.{toLocaleLowerCase,toLocaleUpperCase} requires these locales are listed as `availableLocales`.
+
+            > 7. Let availableLocales be a List with language tags that includes the languages for which the Unicode Character
+            >    Database contains language sensitive case mappings. Implementations may add additional language tags if they
+            >    support case mapping for additional locales.
+
+            https://tc39.es/ecma402/#sup-string.prototype.tolocalelowercase
+
+        This patch adds "el" to our maintained availableLocales list. Previously we only had "az", "lt", and "tr".
+
+        * runtime/StringPrototype.cpp:
+        (JSC::toLocaleCase):
+        (JSC::stringProtoFuncToLocaleUpperCase):
+
 2020-06-12  Keith Miller  <keith_mil...@apple.com>
 
         Tests expecting a crash should use a signal handler in the JSC CLI process

Modified: trunk/Source/_javascript_Core/runtime/StringPrototype.cpp (262991 => 262992)


--- trunk/Source/_javascript_Core/runtime/StringPrototype.cpp	2020-06-13 00:22:31 UTC (rev 262991)
+++ trunk/Source/_javascript_Core/runtime/StringPrototype.cpp	2020-06-13 01:15:20 UTC (rev 262992)
@@ -1582,8 +1582,10 @@
     String noExtensionsLocale = removeUnicodeLocaleExtension(requestedLocale);
 
     // 10. Let availableLocales be a List with the language tags of the languages for which the Unicode character database contains language sensitive case mappings.
-    // Note 1: As of Unicode 5.1, the availableLocales list contains the elements "az", "lt", and "tr".
-    const HashSet<String> availableLocales({ "az"_s, "lt"_s, "tr"_s });
+    // Note 1: As of Unicode 5.1, the availableLocales list contains the elements "az", "el", "lt", and "tr".
+    // FIXME: Creating HashSet for these 4 locales every time is inefficient.
+    // https://bugs.webkit.org/show_bug.cgi?id=213158
+    const HashSet<String> availableLocales({ "az"_s, "el"_s, "lt"_s, "tr"_s });
 
     // 11. Let locale be BestAvailableLocale(availableLocales, noExtensionsLocale).
     String locale = bestAvailableLocale(availableLocales, noExtensionsLocale);
@@ -1623,7 +1625,7 @@
     // 13.1.3 String.prototype.toLocaleUpperCase ([locales])
     // http://ecma-international.org/publications/standards/Ecma-402.htm
     // This function interprets a string value as a sequence of code points, as described in ES2015, 6.1.4. This function behaves in exactly the same way as String.prototype.toLocaleLowerCase, except that characters are mapped to their uppercase equivalents as specified in the Unicode character database.
-    return toLocaleCase<CaseConversionMode::Upper>(globalObject,callFrame);
+    return toLocaleCase<CaseConversionMode::Upper>(globalObject, callFrame);
 }
 
 enum {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to