Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: f5430ef75dd3ddb055aaedc365c64b33568b178e
      
https://github.com/WebKit/WebKit/commit/f5430ef75dd3ddb055aaedc365c64b33568b178e
  Author: Chris Dumez <[email protected]>
  Date:   2026-09-17 (Thu, 17 Sep 2026)

  Changed paths:
    M Source/JavaScriptCore/runtime/IntlCache.cpp
    M Source/JavaScriptCore/runtime/IntlCache.h
    M Source/JavaScriptCore/runtime/IntlCollator.cpp
    M Source/JavaScriptCore/runtime/IntlDateTimeFormat.cpp
    M Source/JavaScriptCore/runtime/IntlDateTimeFormat.h
    M Source/JavaScriptCore/runtime/IntlDisplayNames.cpp
    M Source/JavaScriptCore/runtime/IntlDisplayNames.h
    M Source/JavaScriptCore/runtime/IntlDurationFormat.cpp
    M Source/JavaScriptCore/runtime/IntlDurationFormat.h
    M Source/JavaScriptCore/runtime/IntlListFormat.cpp
    M Source/JavaScriptCore/runtime/IntlLocale.cpp
    M Source/JavaScriptCore/runtime/IntlLocale.h
    M Source/JavaScriptCore/runtime/IntlNumberFormat.cpp
    M Source/JavaScriptCore/runtime/IntlNumberFormat.h
    M Source/JavaScriptCore/runtime/IntlObject.cpp
    M Source/JavaScriptCore/runtime/IntlObject.h
    M Source/JavaScriptCore/runtime/IntlPluralRules.cpp
    M Source/JavaScriptCore/runtime/IntlRelativeTimeFormat.cpp
    M Source/JavaScriptCore/runtime/IntlSegmenter.cpp
    M Source/WTF/wtf/text/StringImpl.cpp
    M Source/WTF/wtf/text/StringImpl.h
    M Source/WTF/wtf/text/StringView.cpp
    M Source/WTF/wtf/text/StringView.h
    M Source/WTF/wtf/text/WTFString.cpp
    M Tools/TestWebKitAPI/Tests/WTF/StringView.cpp

  Log Message:
  -----------
  Use encoding-carrying CString types in Intl
https://bugs.webkit.org/show_bug.cgi?id=324324

Reviewed by Yusuke Suzuki and Darin Adler.

The locale identifiers threaded through Intl all have a known encoding where 
they are
produced, but were passed around as untyped CString, so the encoding had to be
re-established at each ICU call.

A locale identifier is ASCII, so these all become ASCIICString, built with
String::ascii() rather than String::utf8(). ASCIICString::data() is already 
const char*,
so the uloc_*/udat_*/unumf_* call sites take it directly and 
legacyCStringPointer() is
gone from Intl.

localeIDBufferForLanguageTagWithNullTerminator() and 
canonicalizeUnicodeLocaleID()
therefore take a plain ASCIICString. IntlCache::canonicalizeUnicodeLocaleID() 
fed the
latter a UTF8CString for a non-ASCII tag; a language tag is ASCII, so it now 
returns
null for such a tag directly, which is what uloc_forLanguageTag() would have 
produced
anyway.

IntlLocale::m_localeID and LocaleIDBuilder::toCanonical() hold ICU canonical 
locale IDs,
and IntlMathematicalValue holds a number's decimal representation; both are 
ASCII, so
they become ASCIICString too.

Add StringView::ascii(), mirroring String::ascii(). Both share a new
StringImpl::asciiForCharacters(), as the utf8() pair already do; 
StringView::ascii() must
not be the one String::ascii() calls, since constructing a StringView takes a 
global lock
in debug builds. It lets canonicalizeUnicodeLocaleID(StringView) and
IntlMathematicalValue::parseString() convert without going through String.

* Source/JavaScriptCore/runtime/IntlCache.cpp:
(JSC::IntlCache::cacheSharedPatternGenerator):
(JSC::IntlCache::getBestDateTimePattern):
(JSC::IntlCache::getFieldDisplayName):
(JSC::IntlCache::canonicalizeUnicodeLocaleID):
* Source/JavaScriptCore/runtime/IntlCache.h:
(JSC::IntlCache::getSharedPatternGenerator):
* Source/JavaScriptCore/runtime/IntlCollator.cpp:
(JSC::IntlCollator::sortLocaleData):
(JSC::IntlCollator::initializeCollator):
* Source/JavaScriptCore/runtime/IntlDateTimeFormat.cpp:
(JSC::openDateFormat):
(JSC::IntlDateTimeFormat::localeData):
(JSC::IntlDateTimeFormat::initializeDateTimeFormat):
(JSC::IntlDateTimeFormat::createDateIntervalFormatIfNecessary):
(JSC::IntlDateTimeFormat::createTemporalIntervalFormat):
* Source/JavaScriptCore/runtime/IntlDateTimeFormat.h:
* Source/JavaScriptCore/runtime/IntlDisplayNames.cpp:
(JSC::IntlDisplayNames::initializeDisplayNames):
(JSC::IntlDisplayNames::of const):
* Source/JavaScriptCore/runtime/IntlDisplayNames.h:
* Source/JavaScriptCore/runtime/IntlDurationFormat.cpp:
(JSC::IntlDurationFormat::initializeDurationFormat):
(JSC::retrieveSeparator):
(JSC::IntlDurationFormat::createNumberFormatterIfNecessary):
* Source/JavaScriptCore/runtime/IntlDurationFormat.h:
(JSC::IntlDurationFormat::dataLocaleWithExtensions const):
* Source/JavaScriptCore/runtime/IntlListFormat.cpp:
(JSC::IntlListFormat::initializeListFormat):
* Source/JavaScriptCore/runtime/IntlLocale.cpp:
(JSC::LocaleIDBuilder::toCanonical):
(JSC::IntlLocale::timeZones):
* Source/JavaScriptCore/runtime/IntlLocale.h:
* Source/JavaScriptCore/runtime/IntlNumberFormat.cpp:
(JSC::IntlNumberFormat::initializeNumberFormat):
(JSC::IntlNumberFormat::createNumberRangeFormatterIfNecessary):
(JSC::IntlMathematicalValue::parseString):
* Source/JavaScriptCore/runtime/IntlNumberFormat.h:
(JSC::IntlMathematicalValue::IntlMathematicalValue):
(JSC::IntlMathematicalValue::ensureNonDouble):
(JSC::IntlMathematicalValue::getString const):
* Source/JavaScriptCore/runtime/IntlObject.cpp:
(JSC::localeIDBufferForLanguageTagWithNullTerminator):
(JSC::canonicalizeUnicodeLocaleID):
(JSC::numberingSystemsForLocale):
(JSC::defaultNumberingSystemForLocale):
(JSC::defaultCalendarForLocale):
* Source/JavaScriptCore/runtime/IntlObject.h:
* Source/JavaScriptCore/runtime/IntlPluralRules.cpp:
(JSC::IntlPluralRules::initializePluralRules):
* Source/JavaScriptCore/runtime/IntlRelativeTimeFormat.cpp:
(JSC::IntlRelativeTimeFormat::initializeRelativeTimeFormat):
* Source/JavaScriptCore/runtime/IntlSegmenter.cpp:
(JSC::IntlSegmenter::initializeSegmenter):
* Source/WTF/wtf/text/StringImpl.cpp:
(WTF::asciiForCharactersInternal):
(WTF::StringImpl::asciiForCharacters):
* Source/WTF/wtf/text/StringImpl.h:
* Source/WTF/wtf/text/StringView.cpp:
(WTF::StringView::ascii const):
* Source/WTF/wtf/text/StringView.h:
* Source/WTF/wtf/text/WTFString.cpp:
(WTF::String::ascii const):
* Tools/TestWebKitAPI/Tests/WTF/StringView.cpp:
(TestWebKitAPI::TEST):

Canonical link: https://commits.webkit.org/321313@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to