⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 263833 in webkit


Ignore:
Timestamp:
Jul 1, 2020, 11:00:36 PM (6 years ago)
Author:
ysuzuki@apple.com
Message:

[JSC] Intl.Collator should set usage:"search" option through ICU locale
https://bugs.webkit.org/show_bug.cgi?id=213869

Reviewed by Ross Kirsling.

JSTests:

  • stress/intl-collator-co-extension.js: Added.

(shouldBe):
(shouldBeArray):
(explicitTrueBeforeICU67):

  • test262/expectations.yaml:

Source/JavaScriptCore:

Intl.Collator has usage:"search" option, and it affects on collation. However, UCollator does not have an interface to set this collation option,
and only way to configure UCollator is setting "-u-co-search" unicode extension to passed locale string. This patch adds "-u-co-search" unicode
extension if Usage::Search is specified.

  • runtime/IntlCollator.cpp:

(JSC::IntlCollator::initializeCollator):

Location:
trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r263608 r263833  
     12020-07-01  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Intl.Collator should set usage:"search" option through ICU locale
     4        https://bugs.webkit.org/show_bug.cgi?id=213869
     5
     6        Reviewed by Ross Kirsling.
     7
     8        * stress/intl-collator-co-extension.js: Added.
     9        (shouldBe):
     10        (shouldBeArray):
     11        (explicitTrueBeforeICU67):
     12        * test262/expectations.yaml:
     13
    1142020-06-26  Yusuke Suzuki  <ysuzuki@apple.com>
    215
  • trunk/JSTests/test262/expectations.yaml

    r263608 r263833  
    16061606  default: "Test262Error: \"kn-true\" is returned in locale, but shouldn't be. Expected SameValue(«7», «-1») to be true"
    16071607  strict mode: "Test262Error: \"kn-true\" is returned in locale, but shouldn't be. Expected SameValue(«7», «-1») to be true"
    1608 test/intl402/Collator/usage-de.js:
    1609   default: 'Test262Error: Expected [Ä, AE] and [AE, Ä] to have the same contents. search'
    1610   strict mode: 'Test262Error: Expected [Ä, AE] and [AE, Ä] to have the same contents. search'
    16111608test/intl402/DateTimeFormat/prototype/resolvedOptions/hourCycle-default.js:
    16121609  default: 'Test262Error: Expected SameValue(«h24», «h23») to be true'
  • trunk/Source/JavaScriptCore/ChangeLog

    r263824 r263833  
     12020-07-01  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Intl.Collator should set usage:"search" option through ICU locale
     4        https://bugs.webkit.org/show_bug.cgi?id=213869
     5
     6        Reviewed by Ross Kirsling.
     7
     8        Intl.Collator has usage:"search" option, and it affects on collation. However, UCollator does not have an interface to set this collation option,
     9        and only way to configure UCollator is setting "-u-co-search" unicode extension to passed locale string. This patch adds "-u-co-search" unicode
     10        extension if Usage::Search is specified.
     11
     12        * runtime/IntlCollator.cpp:
     13        (JSC::IntlCollator::initializeCollator):
     14
    1152020-07-01  Keith Miller  <keith_miller@apple.com>
    216
  • trunk/Source/JavaScriptCore/runtime/IntlCollator.cpp

    r261755 r263833  
    4444constexpr size_t caseFirstIndex = 1;
    4545constexpr size_t numericIndex = 2;
     46constexpr bool verbose = false;
    4647}
    4748
     
    241242    m_ignorePunctuation = (ignorePunctuation == TriState::True);
    242243
     244    // UCollator does not offer an option to configure "usage" via ucol_setAttribute. So we need to pass this option via locale.
     245    CString dataLocaleWithExtensions;
     246    switch (m_usage) {
     247    case Usage::Sort:
     248        dataLocaleWithExtensions = m_locale.utf8();
     249        break;
     250    case Usage::Search:
     251        // searchLocaleData filters out "co" unicode extension. However, we need to pass "co" to ICU when Usage::Search is specified.
     252        // So we need to pass "co" unicode extension through locale. Since the other relevant extensions are handled via ucol_setAttribute,
     253        // we can just use dataLocale
     254        dataLocaleWithExtensions = makeString(result.get("dataLocale"_s), "-u-co-search").utf8();
     255        break;
     256    }
     257    dataLogLnIf(IntlCollatorInternal::verbose, "dataLocaleWithExtensions:(", dataLocaleWithExtensions, ")");
     258
    243259    UErrorCode status = U_ZERO_ERROR;
    244     m_collator = std::unique_ptr<UCollator, UCollatorDeleter>(ucol_open(m_locale.utf8().data(), &status));
     260    m_collator = std::unique_ptr<UCollator, UCollatorDeleter>(ucol_open(dataLocaleWithExtensions.data(), &status));
    245261    if (U_FAILURE(status)) {
    246262        throwTypeError(globalObject, scope, "failed to initialize Collator"_s);
Note: See TracChangeset for help on using the changeset viewer.