11cb0ef41Sopenharmony_ci// Copyright 2013 the V8 project authors. All rights reserved. 21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be 31cb0ef41Sopenharmony_ci// found in the LICENSE file. 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ci#ifndef V8_INTL_SUPPORT 61cb0ef41Sopenharmony_ci#error Internationalization is expected to be enabled. 71cb0ef41Sopenharmony_ci#endif // V8_INTL_SUPPORT 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ci#ifndef V8_OBJECTS_INTL_OBJECTS_H_ 101cb0ef41Sopenharmony_ci#define V8_OBJECTS_INTL_OBJECTS_H_ 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_ci#include <map> 131cb0ef41Sopenharmony_ci#include <memory> 141cb0ef41Sopenharmony_ci#include <set> 151cb0ef41Sopenharmony_ci#include <string> 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_ci#include "src/base/timezone-cache.h" 181cb0ef41Sopenharmony_ci#include "src/objects/contexts.h" 191cb0ef41Sopenharmony_ci#include "src/objects/managed.h" 201cb0ef41Sopenharmony_ci#include "src/objects/objects.h" 211cb0ef41Sopenharmony_ci#include "unicode/locid.h" 221cb0ef41Sopenharmony_ci#include "unicode/uversion.h" 231cb0ef41Sopenharmony_ci 241cb0ef41Sopenharmony_ci#define V8_MINIMUM_ICU_VERSION 69 251cb0ef41Sopenharmony_ci 261cb0ef41Sopenharmony_cinamespace U_ICU_NAMESPACE { 271cb0ef41Sopenharmony_ciclass BreakIterator; 281cb0ef41Sopenharmony_ciclass Collator; 291cb0ef41Sopenharmony_ciclass FormattedValue; 301cb0ef41Sopenharmony_ciclass StringEnumeration; 311cb0ef41Sopenharmony_ciclass TimeZone; 321cb0ef41Sopenharmony_ciclass UnicodeString; 331cb0ef41Sopenharmony_ci} // namespace U_ICU_NAMESPACE 341cb0ef41Sopenharmony_ci 351cb0ef41Sopenharmony_cinamespace v8 { 361cb0ef41Sopenharmony_cinamespace internal { 371cb0ef41Sopenharmony_ci 381cb0ef41Sopenharmony_cistruct NumberFormatSpan { 391cb0ef41Sopenharmony_ci int32_t field_id; 401cb0ef41Sopenharmony_ci int32_t begin_pos; 411cb0ef41Sopenharmony_ci int32_t end_pos; 421cb0ef41Sopenharmony_ci 431cb0ef41Sopenharmony_ci NumberFormatSpan() = default; 441cb0ef41Sopenharmony_ci NumberFormatSpan(int32_t field_id, int32_t begin_pos, int32_t end_pos) 451cb0ef41Sopenharmony_ci : field_id(field_id), begin_pos(begin_pos), end_pos(end_pos) {} 461cb0ef41Sopenharmony_ci}; 471cb0ef41Sopenharmony_ci 481cb0ef41Sopenharmony_ciV8_EXPORT_PRIVATE std::vector<NumberFormatSpan> FlattenRegionsToParts( 491cb0ef41Sopenharmony_ci std::vector<NumberFormatSpan>* regions); 501cb0ef41Sopenharmony_ci 511cb0ef41Sopenharmony_citemplate <typename T> 521cb0ef41Sopenharmony_ciclass Handle; 531cb0ef41Sopenharmony_ciclass JSCollator; 541cb0ef41Sopenharmony_ci 551cb0ef41Sopenharmony_ciclass Intl { 561cb0ef41Sopenharmony_ci public: 571cb0ef41Sopenharmony_ci enum class BoundFunctionContextSlot { 581cb0ef41Sopenharmony_ci kBoundFunction = Context::MIN_CONTEXT_SLOTS, 591cb0ef41Sopenharmony_ci kLength 601cb0ef41Sopenharmony_ci }; 611cb0ef41Sopenharmony_ci 621cb0ef41Sopenharmony_ci enum class FormatRangeSource { kShared, kStartRange, kEndRange }; 631cb0ef41Sopenharmony_ci 641cb0ef41Sopenharmony_ci class FormatRangeSourceTracker { 651cb0ef41Sopenharmony_ci public: 661cb0ef41Sopenharmony_ci FormatRangeSourceTracker(); 671cb0ef41Sopenharmony_ci void Add(int32_t field, int32_t start, int32_t limit); 681cb0ef41Sopenharmony_ci FormatRangeSource GetSource(int32_t start, int32_t limit) const; 691cb0ef41Sopenharmony_ci 701cb0ef41Sopenharmony_ci private: 711cb0ef41Sopenharmony_ci int32_t start_[2]; 721cb0ef41Sopenharmony_ci int32_t limit_[2]; 731cb0ef41Sopenharmony_ci 741cb0ef41Sopenharmony_ci bool FieldContains(int32_t field, int32_t start, int32_t limit) const; 751cb0ef41Sopenharmony_ci }; 761cb0ef41Sopenharmony_ci 771cb0ef41Sopenharmony_ci static Handle<String> SourceString(Isolate* isolate, 781cb0ef41Sopenharmony_ci FormatRangeSource source); 791cb0ef41Sopenharmony_ci 801cb0ef41Sopenharmony_ci // Build a set of ICU locales from a list of Locales. If there is a locale 811cb0ef41Sopenharmony_ci // with a script tag then the locales also include a locale without the 821cb0ef41Sopenharmony_ci // script; eg, pa_Guru_IN (language=Panjabi, script=Gurmukhi, country-India) 831cb0ef41Sopenharmony_ci // would include pa_IN. 841cb0ef41Sopenharmony_ci static std::set<std::string> BuildLocaleSet( 851cb0ef41Sopenharmony_ci const std::vector<std::string>& locales, const char* path, 861cb0ef41Sopenharmony_ci const char* validate_key); 871cb0ef41Sopenharmony_ci 881cb0ef41Sopenharmony_ci static Maybe<std::string> ToLanguageTag(const icu::Locale& locale); 891cb0ef41Sopenharmony_ci 901cb0ef41Sopenharmony_ci // Get the name of the numbering system from locale. 911cb0ef41Sopenharmony_ci // ICU doesn't expose numbering system in any way, so we have to assume that 921cb0ef41Sopenharmony_ci // for given locale NumberingSystem constructor produces the same digits as 931cb0ef41Sopenharmony_ci // NumberFormat/Calendar would. 941cb0ef41Sopenharmony_ci static std::string GetNumberingSystem(const icu::Locale& icu_locale); 951cb0ef41Sopenharmony_ci 961cb0ef41Sopenharmony_ci static V8_WARN_UNUSED_RESULT MaybeHandle<JSObject> SupportedLocalesOf( 971cb0ef41Sopenharmony_ci Isolate* isolate, const char* method_name, 981cb0ef41Sopenharmony_ci const std::set<std::string>& available_locales, Handle<Object> locales_in, 991cb0ef41Sopenharmony_ci Handle<Object> options_in); 1001cb0ef41Sopenharmony_ci 1011cb0ef41Sopenharmony_ci // https://tc39.github.io/ecma402/#sec-canonicalizelocalelist 1021cb0ef41Sopenharmony_ci // {only_return_one_result} is an optimization for callers that only 1031cb0ef41Sopenharmony_ci // care about the first result. 1041cb0ef41Sopenharmony_ci static Maybe<std::vector<std::string>> CanonicalizeLocaleList( 1051cb0ef41Sopenharmony_ci Isolate* isolate, Handle<Object> locales, 1061cb0ef41Sopenharmony_ci bool only_return_one_result = false); 1071cb0ef41Sopenharmony_ci 1081cb0ef41Sopenharmony_ci // ecma-402 #sec-intl.getcanonicallocales 1091cb0ef41Sopenharmony_ci V8_WARN_UNUSED_RESULT static MaybeHandle<JSArray> GetCanonicalLocales( 1101cb0ef41Sopenharmony_ci Isolate* isolate, Handle<Object> locales); 1111cb0ef41Sopenharmony_ci 1121cb0ef41Sopenharmony_ci // ecma-402 #sec-intl.supportedvaluesof 1131cb0ef41Sopenharmony_ci V8_WARN_UNUSED_RESULT static MaybeHandle<JSArray> SupportedValuesOf( 1141cb0ef41Sopenharmony_ci Isolate* isolate, Handle<Object> key); 1151cb0ef41Sopenharmony_ci 1161cb0ef41Sopenharmony_ci // For locale sensitive functions 1171cb0ef41Sopenharmony_ci V8_WARN_UNUSED_RESULT static MaybeHandle<String> StringLocaleConvertCase( 1181cb0ef41Sopenharmony_ci Isolate* isolate, Handle<String> s, bool is_upper, 1191cb0ef41Sopenharmony_ci Handle<Object> locales); 1201cb0ef41Sopenharmony_ci 1211cb0ef41Sopenharmony_ci V8_WARN_UNUSED_RESULT static MaybeHandle<String> ConvertToUpper( 1221cb0ef41Sopenharmony_ci Isolate* isolate, Handle<String> s); 1231cb0ef41Sopenharmony_ci 1241cb0ef41Sopenharmony_ci V8_WARN_UNUSED_RESULT static MaybeHandle<String> ConvertToLower( 1251cb0ef41Sopenharmony_ci Isolate* isolate, Handle<String> s); 1261cb0ef41Sopenharmony_ci 1271cb0ef41Sopenharmony_ci V8_WARN_UNUSED_RESULT static base::Optional<int> StringLocaleCompare( 1281cb0ef41Sopenharmony_ci Isolate* isolate, Handle<String> s1, Handle<String> s2, 1291cb0ef41Sopenharmony_ci Handle<Object> locales, Handle<Object> options, const char* method_name); 1301cb0ef41Sopenharmony_ci 1311cb0ef41Sopenharmony_ci enum class CompareStringsOptions { 1321cb0ef41Sopenharmony_ci kNone, 1331cb0ef41Sopenharmony_ci kTryFastPath, 1341cb0ef41Sopenharmony_ci }; 1351cb0ef41Sopenharmony_ci template <class IsolateT> 1361cb0ef41Sopenharmony_ci V8_EXPORT_PRIVATE static CompareStringsOptions CompareStringsOptionsFor( 1371cb0ef41Sopenharmony_ci IsolateT* isolate, Handle<Object> locales, Handle<Object> options); 1381cb0ef41Sopenharmony_ci V8_EXPORT_PRIVATE V8_WARN_UNUSED_RESULT static int CompareStrings( 1391cb0ef41Sopenharmony_ci Isolate* isolate, const icu::Collator& collator, Handle<String> s1, 1401cb0ef41Sopenharmony_ci Handle<String> s2, 1411cb0ef41Sopenharmony_ci CompareStringsOptions compare_strings_options = 1421cb0ef41Sopenharmony_ci CompareStringsOptions::kNone); 1431cb0ef41Sopenharmony_ci 1441cb0ef41Sopenharmony_ci // ecma402/#sup-properties-of-the-number-prototype-object 1451cb0ef41Sopenharmony_ci V8_WARN_UNUSED_RESULT static MaybeHandle<String> NumberToLocaleString( 1461cb0ef41Sopenharmony_ci Isolate* isolate, Handle<Object> num, Handle<Object> locales, 1471cb0ef41Sopenharmony_ci Handle<Object> options, const char* method_name); 1481cb0ef41Sopenharmony_ci 1491cb0ef41Sopenharmony_ci // [[RoundingPriority]] is one of the String values "auto", "morePrecision", 1501cb0ef41Sopenharmony_ci // or "lessPrecision", specifying the rounding priority for the number. 1511cb0ef41Sopenharmony_ci enum class RoundingPriority { 1521cb0ef41Sopenharmony_ci kAuto, 1531cb0ef41Sopenharmony_ci kMorePrecision, 1541cb0ef41Sopenharmony_ci kLessPrecision, 1551cb0ef41Sopenharmony_ci }; 1561cb0ef41Sopenharmony_ci 1571cb0ef41Sopenharmony_ci enum class RoundingType { 1581cb0ef41Sopenharmony_ci kFractionDigits, 1591cb0ef41Sopenharmony_ci kSignificantDigits, 1601cb0ef41Sopenharmony_ci kMorePrecision, 1611cb0ef41Sopenharmony_ci kLessPrecision, 1621cb0ef41Sopenharmony_ci }; 1631cb0ef41Sopenharmony_ci 1641cb0ef41Sopenharmony_ci // ecma402/#sec-setnfdigitoptions 1651cb0ef41Sopenharmony_ci struct NumberFormatDigitOptions { 1661cb0ef41Sopenharmony_ci int minimum_integer_digits; 1671cb0ef41Sopenharmony_ci int minimum_fraction_digits; 1681cb0ef41Sopenharmony_ci int maximum_fraction_digits; 1691cb0ef41Sopenharmony_ci int minimum_significant_digits; 1701cb0ef41Sopenharmony_ci int maximum_significant_digits; 1711cb0ef41Sopenharmony_ci RoundingPriority rounding_priority; 1721cb0ef41Sopenharmony_ci RoundingType rounding_type; 1731cb0ef41Sopenharmony_ci }; 1741cb0ef41Sopenharmony_ci V8_WARN_UNUSED_RESULT static Maybe<NumberFormatDigitOptions> 1751cb0ef41Sopenharmony_ci SetNumberFormatDigitOptions(Isolate* isolate, Handle<JSReceiver> options, 1761cb0ef41Sopenharmony_ci int mnfd_default, int mxfd_default, 1771cb0ef41Sopenharmony_ci bool notation_is_compact); 1781cb0ef41Sopenharmony_ci 1791cb0ef41Sopenharmony_ci // Helper function to convert a UnicodeString to a Handle<String> 1801cb0ef41Sopenharmony_ci V8_WARN_UNUSED_RESULT static MaybeHandle<String> ToString( 1811cb0ef41Sopenharmony_ci Isolate* isolate, const icu::UnicodeString& string); 1821cb0ef41Sopenharmony_ci 1831cb0ef41Sopenharmony_ci // Helper function to convert a substring of UnicodeString to a Handle<String> 1841cb0ef41Sopenharmony_ci V8_WARN_UNUSED_RESULT static MaybeHandle<String> ToString( 1851cb0ef41Sopenharmony_ci Isolate* isolate, const icu::UnicodeString& string, int32_t begin, 1861cb0ef41Sopenharmony_ci int32_t end); 1871cb0ef41Sopenharmony_ci 1881cb0ef41Sopenharmony_ci // Helper function to convert a FormattedValue to String 1891cb0ef41Sopenharmony_ci V8_WARN_UNUSED_RESULT static MaybeHandle<String> FormattedToString( 1901cb0ef41Sopenharmony_ci Isolate* isolate, const icu::FormattedValue& formatted); 1911cb0ef41Sopenharmony_ci 1921cb0ef41Sopenharmony_ci // Helper function to convert number field id to type string. 1931cb0ef41Sopenharmony_ci static Handle<String> NumberFieldToType(Isolate* isolate, 1941cb0ef41Sopenharmony_ci const NumberFormatSpan& part, 1951cb0ef41Sopenharmony_ci const icu::UnicodeString& text, 1961cb0ef41Sopenharmony_ci bool is_nan); 1971cb0ef41Sopenharmony_ci 1981cb0ef41Sopenharmony_ci // A helper function to implement formatToParts which add element to array as 1991cb0ef41Sopenharmony_ci // $array[$index] = { type: $field_type_string, value: $value } 2001cb0ef41Sopenharmony_ci static void AddElement(Isolate* isolate, Handle<JSArray> array, int index, 2011cb0ef41Sopenharmony_ci Handle<String> field_type_string, 2021cb0ef41Sopenharmony_ci Handle<String> value); 2031cb0ef41Sopenharmony_ci 2041cb0ef41Sopenharmony_ci // A helper function to implement formatToParts which add element to array as 2051cb0ef41Sopenharmony_ci // $array[$index] = { 2061cb0ef41Sopenharmony_ci // type: $field_type_string, value: $value, 2071cb0ef41Sopenharmony_ci // $additional_property_name: $additional_property_value 2081cb0ef41Sopenharmony_ci // } 2091cb0ef41Sopenharmony_ci static void AddElement(Isolate* isolate, Handle<JSArray> array, int index, 2101cb0ef41Sopenharmony_ci Handle<String> field_type_string, Handle<String> value, 2111cb0ef41Sopenharmony_ci Handle<String> additional_property_name, 2121cb0ef41Sopenharmony_ci Handle<String> additional_property_value); 2131cb0ef41Sopenharmony_ci 2141cb0ef41Sopenharmony_ci // In ECMA 402 v1, Intl constructors supported a mode of operation 2151cb0ef41Sopenharmony_ci // where calling them with an existing object as a receiver would 2161cb0ef41Sopenharmony_ci // transform the receiver into the relevant Intl instance with all 2171cb0ef41Sopenharmony_ci // internal slots. In ECMA 402 v2, this capability was removed, to 2181cb0ef41Sopenharmony_ci // avoid adding internal slots on existing objects. In ECMA 402 v3, 2191cb0ef41Sopenharmony_ci // the capability was re-added as "normative optional" in a mode 2201cb0ef41Sopenharmony_ci // which chains the underlying Intl instance on any object, when the 2211cb0ef41Sopenharmony_ci // constructor is called 2221cb0ef41Sopenharmony_ci // 2231cb0ef41Sopenharmony_ci // See ecma402/#legacy-constructor. 2241cb0ef41Sopenharmony_ci V8_WARN_UNUSED_RESULT static MaybeHandle<Object> LegacyUnwrapReceiver( 2251cb0ef41Sopenharmony_ci Isolate* isolate, Handle<JSReceiver> receiver, 2261cb0ef41Sopenharmony_ci Handle<JSFunction> constructor, bool has_initialized_slot); 2271cb0ef41Sopenharmony_ci 2281cb0ef41Sopenharmony_ci // enum for "localeMatcher" option: shared by many Intl objects. 2291cb0ef41Sopenharmony_ci enum class MatcherOption { kBestFit, kLookup }; 2301cb0ef41Sopenharmony_ci 2311cb0ef41Sopenharmony_ci // Shared function to read the "localeMatcher" option. 2321cb0ef41Sopenharmony_ci V8_WARN_UNUSED_RESULT static Maybe<MatcherOption> GetLocaleMatcher( 2331cb0ef41Sopenharmony_ci Isolate* isolate, Handle<JSReceiver> options, const char* method_name); 2341cb0ef41Sopenharmony_ci 2351cb0ef41Sopenharmony_ci // Shared function to read the "numberingSystem" option. 2361cb0ef41Sopenharmony_ci V8_WARN_UNUSED_RESULT static Maybe<bool> GetNumberingSystem( 2371cb0ef41Sopenharmony_ci Isolate* isolate, Handle<JSReceiver> options, const char* method_name, 2381cb0ef41Sopenharmony_ci std::unique_ptr<char[]>* result); 2391cb0ef41Sopenharmony_ci 2401cb0ef41Sopenharmony_ci // Check the calendar is valid or not for that locale. 2411cb0ef41Sopenharmony_ci static bool IsValidCalendar(const icu::Locale& locale, 2421cb0ef41Sopenharmony_ci const std::string& value); 2431cb0ef41Sopenharmony_ci 2441cb0ef41Sopenharmony_ci // Check the collation is valid or not for that locale. 2451cb0ef41Sopenharmony_ci static bool IsValidCollation(const icu::Locale& locale, 2461cb0ef41Sopenharmony_ci const std::string& value); 2471cb0ef41Sopenharmony_ci 2481cb0ef41Sopenharmony_ci // Check the numberingSystem is valid. 2491cb0ef41Sopenharmony_ci static bool IsValidNumberingSystem(const std::string& value); 2501cb0ef41Sopenharmony_ci 2511cb0ef41Sopenharmony_ci // Check the calendar is well formed. 2521cb0ef41Sopenharmony_ci static bool IsWellFormedCalendar(const std::string& value); 2531cb0ef41Sopenharmony_ci 2541cb0ef41Sopenharmony_ci // Check the currency is well formed. 2551cb0ef41Sopenharmony_ci static bool IsWellFormedCurrency(const std::string& value); 2561cb0ef41Sopenharmony_ci 2571cb0ef41Sopenharmony_ci struct ResolvedLocale { 2581cb0ef41Sopenharmony_ci std::string locale; 2591cb0ef41Sopenharmony_ci icu::Locale icu_locale; 2601cb0ef41Sopenharmony_ci std::map<std::string, std::string> extensions; 2611cb0ef41Sopenharmony_ci }; 2621cb0ef41Sopenharmony_ci 2631cb0ef41Sopenharmony_ci static Maybe<ResolvedLocale> ResolveLocale( 2641cb0ef41Sopenharmony_ci Isolate* isolate, const std::set<std::string>& available_locales, 2651cb0ef41Sopenharmony_ci const std::vector<std::string>& requested_locales, MatcherOption options, 2661cb0ef41Sopenharmony_ci const std::set<std::string>& relevant_extension_keys); 2671cb0ef41Sopenharmony_ci 2681cb0ef41Sopenharmony_ci // A helper template to implement the GetAvailableLocales 2691cb0ef41Sopenharmony_ci // Usage in src/objects/js-XXX.cc 2701cb0ef41Sopenharmony_ci // const std::set<std::string>& JSXxx::GetAvailableLocales() { 2711cb0ef41Sopenharmony_ci // static base::LazyInstance<Intl::AvailableLocales<icu::YYY>>::type 2721cb0ef41Sopenharmony_ci // available_locales = LAZY_INSTANCE_INITIALIZER; 2731cb0ef41Sopenharmony_ci // return available_locales.Pointer()->Get(); 2741cb0ef41Sopenharmony_ci // } 2751cb0ef41Sopenharmony_ci 2761cb0ef41Sopenharmony_ci struct SkipResourceCheck { 2771cb0ef41Sopenharmony_ci static const char* key() { return nullptr; } 2781cb0ef41Sopenharmony_ci static const char* path() { return nullptr; } 2791cb0ef41Sopenharmony_ci }; 2801cb0ef41Sopenharmony_ci 2811cb0ef41Sopenharmony_ci template <typename C = SkipResourceCheck> 2821cb0ef41Sopenharmony_ci class AvailableLocales { 2831cb0ef41Sopenharmony_ci public: 2841cb0ef41Sopenharmony_ci AvailableLocales() { 2851cb0ef41Sopenharmony_ci UErrorCode status = U_ZERO_ERROR; 2861cb0ef41Sopenharmony_ci UEnumeration* uenum = 2871cb0ef41Sopenharmony_ci uloc_openAvailableByType(ULOC_AVAILABLE_WITH_LEGACY_ALIASES, &status); 2881cb0ef41Sopenharmony_ci DCHECK(U_SUCCESS(status)); 2891cb0ef41Sopenharmony_ci 2901cb0ef41Sopenharmony_ci std::vector<std::string> all_locales; 2911cb0ef41Sopenharmony_ci const char* loc; 2921cb0ef41Sopenharmony_ci while ((loc = uenum_next(uenum, nullptr, &status)) != nullptr) { 2931cb0ef41Sopenharmony_ci DCHECK(U_SUCCESS(status)); 2941cb0ef41Sopenharmony_ci std::string locstr(loc); 2951cb0ef41Sopenharmony_ci std::replace(locstr.begin(), locstr.end(), '_', '-'); 2961cb0ef41Sopenharmony_ci // Handle special case 2971cb0ef41Sopenharmony_ci if (locstr == "en-US-POSIX") locstr = "en-US-u-va-posix"; 2981cb0ef41Sopenharmony_ci all_locales.push_back(locstr); 2991cb0ef41Sopenharmony_ci } 3001cb0ef41Sopenharmony_ci uenum_close(uenum); 3011cb0ef41Sopenharmony_ci 3021cb0ef41Sopenharmony_ci set_ = Intl::BuildLocaleSet(all_locales, C::path(), C::key()); 3031cb0ef41Sopenharmony_ci } 3041cb0ef41Sopenharmony_ci const std::set<std::string>& Get() const { return set_; } 3051cb0ef41Sopenharmony_ci 3061cb0ef41Sopenharmony_ci private: 3071cb0ef41Sopenharmony_ci std::set<std::string> set_; 3081cb0ef41Sopenharmony_ci }; 3091cb0ef41Sopenharmony_ci 3101cb0ef41Sopenharmony_ci // Utility function to set text to BreakIterator. 3111cb0ef41Sopenharmony_ci static Handle<Managed<icu::UnicodeString>> SetTextToBreakIterator( 3121cb0ef41Sopenharmony_ci Isolate* isolate, Handle<String> text, 3131cb0ef41Sopenharmony_ci icu::BreakIterator* break_iterator); 3141cb0ef41Sopenharmony_ci 3151cb0ef41Sopenharmony_ci // ecma262 #sec-string.prototype.normalize 3161cb0ef41Sopenharmony_ci V8_WARN_UNUSED_RESULT static MaybeHandle<String> Normalize( 3171cb0ef41Sopenharmony_ci Isolate* isolate, Handle<String> string, Handle<Object> form_input); 3181cb0ef41Sopenharmony_ci static base::TimezoneCache* CreateTimeZoneCache(); 3191cb0ef41Sopenharmony_ci 3201cb0ef41Sopenharmony_ci // Convert a Handle<String> to icu::UnicodeString 3211cb0ef41Sopenharmony_ci static icu::UnicodeString ToICUUnicodeString(Isolate* isolate, 3221cb0ef41Sopenharmony_ci Handle<String> string, 3231cb0ef41Sopenharmony_ci int offset = 0); 3241cb0ef41Sopenharmony_ci 3251cb0ef41Sopenharmony_ci static const uint8_t* ToLatin1LowerTable(); 3261cb0ef41Sopenharmony_ci 3271cb0ef41Sopenharmony_ci static const uint8_t* AsciiCollationWeightsL1(); 3281cb0ef41Sopenharmony_ci static const uint8_t* AsciiCollationWeightsL3(); 3291cb0ef41Sopenharmony_ci static const int kAsciiCollationWeightsLength; 3301cb0ef41Sopenharmony_ci 3311cb0ef41Sopenharmony_ci static String ConvertOneByteToLower(String src, String dst); 3321cb0ef41Sopenharmony_ci 3331cb0ef41Sopenharmony_ci static const std::set<std::string>& GetAvailableLocales(); 3341cb0ef41Sopenharmony_ci 3351cb0ef41Sopenharmony_ci static const std::set<std::string>& GetAvailableLocalesForDateFormat(); 3361cb0ef41Sopenharmony_ci 3371cb0ef41Sopenharmony_ci V8_WARN_UNUSED_RESULT static MaybeHandle<JSArray> ToJSArray( 3381cb0ef41Sopenharmony_ci Isolate* isolate, const char* unicode_key, 3391cb0ef41Sopenharmony_ci icu::StringEnumeration* enumeration, 3401cb0ef41Sopenharmony_ci const std::function<bool(const char*)>& removes, bool sort); 3411cb0ef41Sopenharmony_ci 3421cb0ef41Sopenharmony_ci static bool RemoveCollation(const char* collation); 3431cb0ef41Sopenharmony_ci 3441cb0ef41Sopenharmony_ci static std::set<std::string> SanctionedSimpleUnits(); 3451cb0ef41Sopenharmony_ci 3461cb0ef41Sopenharmony_ci V8_WARN_UNUSED_RESULT static MaybeHandle<JSArray> AvailableCalendars( 3471cb0ef41Sopenharmony_ci Isolate* isolate); 3481cb0ef41Sopenharmony_ci 3491cb0ef41Sopenharmony_ci V8_WARN_UNUSED_RESULT static bool IsValidTimeZoneName( 3501cb0ef41Sopenharmony_ci const icu::TimeZone& tz); 3511cb0ef41Sopenharmony_ci V8_WARN_UNUSED_RESULT static bool IsValidTimeZoneName(Isolate* isolate, 3521cb0ef41Sopenharmony_ci const std::string& id); 3531cb0ef41Sopenharmony_ci V8_WARN_UNUSED_RESULT static bool IsValidTimeZoneName(Isolate* isolate, 3541cb0ef41Sopenharmony_ci Handle<String> id); 3551cb0ef41Sopenharmony_ci 3561cb0ef41Sopenharmony_ci // Function to support Temporal 3571cb0ef41Sopenharmony_ci V8_WARN_UNUSED_RESULT static std::string TimeZoneIdFromIndex(int32_t index); 3581cb0ef41Sopenharmony_ci 3591cb0ef41Sopenharmony_ci V8_WARN_UNUSED_RESULT static Maybe<bool> GetTimeZoneIndex( 3601cb0ef41Sopenharmony_ci Isolate* isolate, Handle<String> identifier, int32_t* index); 3611cb0ef41Sopenharmony_ci 3621cb0ef41Sopenharmony_ci V8_WARN_UNUSED_RESULT static MaybeHandle<String> CanonicalizeTimeZoneName( 3631cb0ef41Sopenharmony_ci Isolate* isolate, Handle<String> identifier); 3641cb0ef41Sopenharmony_ci 3651cb0ef41Sopenharmony_ci // ecma402/#sec-coerceoptionstoobject 3661cb0ef41Sopenharmony_ci V8_WARN_UNUSED_RESULT static MaybeHandle<JSReceiver> CoerceOptionsToObject( 3671cb0ef41Sopenharmony_ci Isolate* isolate, Handle<Object> options, const char* service); 3681cb0ef41Sopenharmony_ci 3691cb0ef41Sopenharmony_ci // #sec-tointlmathematicalvalue 3701cb0ef41Sopenharmony_ci // The implementation preserve the Object in String, BigInt or Number 3711cb0ef41Sopenharmony_ci V8_WARN_UNUSED_RESULT static MaybeHandle<Object> 3721cb0ef41Sopenharmony_ci ToIntlMathematicalValueAsNumberBigIntOrString(Isolate* isolate, 3731cb0ef41Sopenharmony_ci Handle<Object> input); 3741cb0ef41Sopenharmony_ci}; 3751cb0ef41Sopenharmony_ci 3761cb0ef41Sopenharmony_ci} // namespace internal 3771cb0ef41Sopenharmony_ci} // namespace v8 3781cb0ef41Sopenharmony_ci 3791cb0ef41Sopenharmony_ci#endif // V8_OBJECTS_INTL_OBJECTS_H_ 380