Lines Matching defs:string

13 #include <string>
33 #include "src/objects/string.h"
34 #include "src/strings/string-case.h"
135 // Since this upper-cased character does not fit in an 8-bit string, we
200 Handle<String> string, int offset) {
201 DCHECK(string->IsFlat());
209 const String::FlatContent& flat = string->GetFlatContent(no_gc);
210 int32_t length = string->length();
223 icu::StringPiece ToICUStringPiece(Isolate* isolate, Handle<String> string,
225 DCHECK(string->IsFlat());
228 const String::FlatContent& flat = string->GetFlatContent(no_gc);
231 int32_t length = string->length();
256 // Case conversion can increase the string length (e.g. sharp-S => SS) so
273 // leading to an unterminated string (U_STRING_NOT_TERMINATED_WARNING).
289 // one-byte sliced string with a two-byte parent string.
345 // string is invariant under ToLowerCase, and the result always
349 // Scan the string for uppercase and non-ASCII characters for strings
431 std::string Intl::GetNumberingSystem(const icu::Locale& icu_locale) {
446 Maybe<icu::Locale> CreateICULocale(const std::string& bcp47_locale) {
466 const icu::UnicodeString& string) {
468 reinterpret_cast<const uint16_t*>(string.getBuffer()), string.length()));
472 const icu::UnicodeString& string,
474 return Intl::ToString(isolate, string.tempSubStringBetween(begin, end));
529 // script else return false and an empty string.
530 bool RemoveLocaleScriptTag(const std::string& icu_locale,
531 std::string* locale_less_script) {
535 *locale_less_script = std::string();
565 std::string without_country(locale.getLanguage());
571 std::string language(locale.getLanguage());
580 std::set<std::string> Intl::BuildLocaleSet(
581 const std::vector<std::string>& icu_available_locales, const char* path,
583 std::set<std::string> locales;
584 for (const std::string& locale : icu_available_locales) {
598 std::string shortened_locale;
607 Maybe<std::string> Intl::ToLanguageTag(const icu::Locale& locale) {
609 std::string res = locale.toLanguageTag<std::string>(status);
611 return Nothing<std::string>();
646 bool IsTwoLetterLanguage(const std::string& locale) {
652 bool IsDeprecatedOrLegacyLanguage(const std::string& locale) {
660 bool IsStructurallyValidLanguageTag(const std::string& tag) {
667 Maybe<std::string> CanonicalizeLanguageTag(Isolate* isolate,
668 const std::string& locale_in) {
669 std::string locale = locale_in;
678 Nothing<std::string>());
715 Nothing<std::string>());
727 Nothing<std::string>());
729 Maybe<std::string> maybe_to_language_tag = Intl::ToLanguageTag(icu_locale);
736 Nothing<std::string>());
742 Maybe<std::string> CanonicalizeLanguageTag(Isolate* isolate,
757 Nothing<std::string>());
761 Nothing<std::string>());
763 std::string locale(locale_str->ToCString().get());
768 Nothing<std::string>());
775 Maybe<std::vector<std::string>> Intl::CanonicalizeLocaleList(
780 return Just(std::vector<std::string>());
783 std::vector<std::string> seen;
797 std::string canonicalized_tag;
799 return Nothing<std::vector<std::string>>();
809 Nothing<std::vector<std::string>>());
814 Nothing<std::vector<std::string>>());
829 MAYBE_RETURN(maybe_found, Nothing<std::vector<std::string>>());
835 Nothing<std::vector<std::string>>());
840 std::string canonicalized_tag;
851 return Nothing<std::vector<std::string>>();
867 // ecma402 #sup-string.prototype.tolocalelowercase
868 // ecma402 #sup-string.prototype.tolocaleuppercase
873 std::vector<std::string> requested_locales;
877 std::string requested_locale = requested_locales.size() == 0
881 if (dash != std::string::npos) {
938 const std::string& default_locale = isolate->DefaultLocale();
969 // We only cache the instance when locales is a string/undefined and
1174 bool CharIsAsciiOrOutOfBounds(const String::FlatContent& string,
1176 DCHECK_EQ(string.length(), string_length);
1177 return index >= string_length || isascii(string.Get(index));
1180 bool CharCanFastCompareOrOutOfBounds(const String::FlatContent& string,
1182 DCHECK_EQ(string.length(), string_length);
1183 return index >= string_length || CanFastCompare(string.Get(index));
1201 // Empty string or a range.
1204 // A non-empty string.
1320 // // longer string is treated as 'greater'.
1338 // by implementing comparison through string iteration. This has visible
1384 // string has a fully ignored suffix, e.g. "a" vs. "a\u{1}".
1468 // We only cache the instance when locales is a string/undefined and
1566 // "string", « "auto", "morePrecision", "lessPrecision" », "auto").
1720 std::string BestAvailableLocale(const std::set<std::string>& available_locales,
1721 const std::string& locale) {
1723 std::string candidate = locale;
1737 if (pos == std::string::npos) {
1738 return std::string();
1754 std::string no_extensions_locale;
1755 std::string extension;
1763 ParsedLocale ParseBCP47Locale(const std::string& locale) {
1780 if (unicode_extension_start == std::string::npos) {
1788 if (private_extension_start != std::string::npos &&
1794 const std::string beginning = locale.substr(0, unicode_extension_start);
1811 const std::string end = locale.substr(unicode_extension_end);
1819 std::vector<std::string> LookupSupportedLocales(
1820 const std::set<std::string>& available_locales,
1821 const std::vector<std::string>& requested_locales) {
1823 std::vector<std::string> subset;
1826 for (const std::string& locale : requested_locales) {
1829 std::string no_extension_locale =
1834 std::string available_locale =
1849 Isolate* isolate, const std::set<std::string>& available_locales,
1872 Iterator(std::vector<std::string>::const_iterator begin,
1873 std::vector<std::string>::const_iterator end)
1888 std::vector<std::string>::const_iterator iter_;
1889 std::vector<std::string>::const_iterator end_;
1909 std::string BestFitMatcher(Isolate* isolate,
1910 const std::set<std::string>& available_locales,
1911 const std::vector<std::string>& requested_locales) {
1914 std::string bestfit = BuildLocaleMatcher(isolate, available_locales, &status)
1917 .toLanguageTag<std::string>(status);
1924 std::vector<std::string> BestFitSupportedLocales(
1925 Isolate* isolate, const std::set<std::string>& available_locales,
1926 const std::vector<std::string>& requested_locales) {
1930 std::vector<std::string> result;
1946 std::string bestfit = desired.toLanguageTag<std::string>(status);
1956 std::vector<std::string> elements,
1967 const std::string& part = elements[i];
1982 const std::set<std::string>& available_locales,
1983 const std::vector<std::string>& requested_locales, Handle<Object> options) {
1984 std::vector<std::string> supported_locales;
1992 // 2. Let matcher be ? GetOption(options, "localeMatcher", "string",
2025 Maybe<std::vector<std::string>> maybe_ll =
2049 const std::vector<std::string>& array) {
2054 for (std::string item : array) {
2088 const std::vector<std::string>& Get() const { return list_; }
2104 std::vector<std::string> list_;
2107 const std::vector<std::string>& GetAvailableCurrencies() {
2153 std::set<std::string> sanctioned(Intl::SanctionedSimpleUnits());
2157 for (std::string item : sanctioned) {
2218 const std::set<std::string>& available_locales, Handle<Object> locales,
2223 Maybe<std::vector<std::string>> requested_locales =
2236 const std::string& value) {
2262 const std::string& value) {
2263 std::set<std::string> invalid_values = {"standard", "search"};
2268 bool Intl::IsWellFormedCalendar(const std::string& value) {
2273 bool Intl::IsWellFormedCurrency(const std::string& currency) {
2278 const std::string& value) {
2282 bool Intl::IsValidNumberingSystem(const std::string& value) {
2283 std::set<std::string> invalid_values = {"native", "traditio", "finance"};
2294 bool IsWellFormedNumberingSystem(const std::string& value) {
2298 std::map<std::string, std::string> LookupAndValidateUnicodeExtensions(
2299 icu::Locale* icu_locale, const std::set<std::string>& relevant_keys) {
2300 std::map<std::string, std::string> extensions;
2346 std::set<std::string> valid_values = {"h11", "h12", "h23", "h24"};
2350 std::set<std::string> valid_values = {"strict", "normal", "loose"};
2354 std::set<std::string> valid_values = {"true", "false"};
2358 std::set<std::string> valid_values = {"upper", "lower", "false"};
2365 std::pair<std::string, std::string>(bcp47_key, bcp47_value));
2378 std::string LookupMatcher(Isolate* isolate,
2379 const std::set<std::string>& available_locales,
2380 const std::vector<std::string>& requested_locales) {
2382 std::string result;
2385 for (const std::string& locale : requested_locales) {
2389 std::string no_extensions_locale = parsed_locale.no_extensions_locale;
2393 std::string available_locale =
2428 // we use ICU to do all the string manipulations that the spec
2438 Isolate* isolate, const std::set<std::string>& available_locales,
2439 const std::vector<std::string>& requested_locales, MatcherOption matcher,
2440 const std::set<std::string>& relevant_extension_keys) {
2441 std::string locale;
2452 std::map<std::string, std::string> extensions =
2455 std::string canonicalized_locale = Intl::ToLanguageTag(icu_locale).FromJust();
2476 // ecma262 #sec-string.prototype.normalize
2477 MaybeHandle<String> Intl::Normalize(Isolate* isolate, Handle<String> string,
2515 int length = string->length();
2516 string = String::Flatten(isolate, string);
2520 icu::UnicodeString input = ToICUUnicodeString(isolate, string);
2529 if (length == normalized_prefix_length) return string;
2568 std::string timezone_name_;
2569 std::string dst_timezone_name_;
2574 std::string* name = is_dst ? &dst_timezone_name_ : &timezone_name_;
2580 icu::StringByteSink<std::string> byte_sink(name);
2670 const std::set<std::string>& Intl::GetAvailableLocales() {
2685 const std::set<std::string>& Intl::GetAvailableLocalesForDateFormat() {
2761 std::vector<std::string> array;
2784 std::set<std::string> Intl::SanctionedSimpleUnits() {
2785 return std::set<std::string>({"acre", "bit", "byte",
2817 std::string time_zone =
2832 std::string time_zone =
2846 std::string Intl::TimeZoneIdFromIndex(int32_t index) {
2871 std::string identifier_str(identifier->ToCString().get());