summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.cpp8
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.cpp12
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp8
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp28
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/Intl.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.cpp34
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormat.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatPrototype.cpp8
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.cpp2
18 files changed, 72 insertions, 70 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.cpp
index 33112fc658..c5bc4ba8cc 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.cpp
@@ -383,7 +383,7 @@ ThrowCompletionOr<LocaleResult> resolve_locale(Vector<DeprecatedString> const& r
MatcherResult matcher_result;
// 2. If matcher is "lookup", then
- if (matcher.is_string() && (TRY(matcher.as_string().deprecated_string()) == "lookup"sv)) {
+ if (matcher.is_string() && (TRY(matcher.as_string().utf8_string_view()) == "lookup"sv)) {
// a. Let r be ! LookupMatcher(availableLocales, requestedLocales).
matcher_result = lookup_matcher(requested_locales);
}
@@ -575,7 +575,7 @@ ThrowCompletionOr<Array*> supported_locales(VM& vm, Vector<DeprecatedString> con
Vector<DeprecatedString> supported_locales;
// 3. If matcher is "best fit", then
- if (TRY(matcher.as_string().deprecated_string()) == "best fit"sv) {
+ if (TRY(matcher.as_string().utf8_string_view()) == "best fit"sv) {
// a. Let supportedLocales be BestFitSupportedLocales(availableLocales, requestedLocales).
supported_locales = best_fit_supported_locales(requested_locales);
}
@@ -628,7 +628,7 @@ ThrowCompletionOr<StringOrBoolean> get_string_or_boolean_option(VM& vm, Object c
return falsy_value;
// 6. Let value be ? ToString(value).
- auto value_string = TRY(value.to_deprecated_string(vm));
+ auto value_string = TRY(value.to_string(vm));
// 7. NOTE: For historical reasons, the strings "true" and "false" are treated the same as the boolean value true.
// 8. If value is "true" or "false", return fallback.
@@ -636,7 +636,7 @@ ThrowCompletionOr<StringOrBoolean> get_string_or_boolean_option(VM& vm, Object c
return fallback;
// 9. If values does not contain an element equal to value, throw a RangeError exception.
- auto it = find(values.begin(), values.end(), value_string);
+ auto it = find(values.begin(), values.end(), value_string.bytes_as_string_view());
if (it == values.end())
return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, value_string, property.as_string());
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.cpp b/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.cpp
index c5a43d660b..904e2c9de8 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.cpp
@@ -58,12 +58,12 @@ ThrowCompletionOr<Value> CollatorCompareFunction::call()
// 4. If y is not provided, let y be undefined.
// 5. Let X be ? ToString(x).
- auto x = TRY(vm.argument(0).to_deprecated_string(vm));
+ auto x = TRY(vm.argument(0).to_string(vm));
// 6. Let Y be ? ToString(y).
- auto y = TRY(vm.argument(1).to_deprecated_string(vm));
+ auto y = TRY(vm.argument(1).to_string(vm));
// 7. Return CompareStrings(collator, X, Y).
- return compare_strings(m_collator, Utf8View(x), Utf8View(y));
+ return compare_strings(m_collator, x.code_points(), y.code_points());
}
void CollatorCompareFunction::visit_edges(Visitor& visitor)
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.cpp
index 37266a1fdb..9f1775e5b6 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.cpp
@@ -27,7 +27,7 @@ static ThrowCompletionOr<Collator*> initialize_collator(VM& vm, Collator& collat
auto usage = TRY(get_option(vm, *options, vm.names.usage, OptionType::String, { "sort"sv, "search"sv }, "sort"sv));
// 4. Set collator.[[Usage]] to usage.
- collator.set_usage(TRY(usage.as_string().deprecated_string()));
+ collator.set_usage(TRY(usage.as_string().utf8_string_view()));
// 5. If usage is "sort", then
// a. Let localeData be %Collator%.[[SortLocaleData]].
@@ -49,7 +49,7 @@ static ThrowCompletionOr<Collator*> initialize_collator(VM& vm, Collator& collat
// 11. If collation is not undefined, then
if (!collation.is_undefined()) {
// a. If collation does not match the Unicode Locale Identifier type nonterminal, throw a RangeError exception.
- if (!::Locale::is_type_identifier(TRY(collation.as_string().deprecated_string())))
+ if (!::Locale::is_type_identifier(TRY(collation.as_string().utf8_string_view())))
return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, collation, "collation"sv);
// 12. Set opt.[[co]] to collation.
@@ -117,7 +117,7 @@ static ThrowCompletionOr<Collator*> initialize_collator(VM& vm, Collator& collat
}
// 28. Set collator.[[Sensitivity]] to sensitivity.
- collator.set_sensitivity(TRY(sensitivity.as_string().deprecated_string()));
+ collator.set_sensitivity(TRY(sensitivity.as_string().utf8_string_view()));
// 29. Let ignorePunctuation be ? GetOption(options, "ignorePunctuation", boolean, empty, false).
auto ignore_punctuation = TRY(get_option(vm, *options, vm.names.ignorePunctuation, OptionType::Boolean, {}, false));
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.cpp
index 8b1e31cc59..7c61b9e5f6 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.cpp
@@ -106,7 +106,7 @@ ThrowCompletionOr<DateTimeFormat*> initialize_date_time_format(VM& vm, DateTimeF
// 7. If calendar is not undefined, then
if (!calendar.is_undefined()) {
// a. If calendar does not match the Unicode Locale Identifier type nonterminal, throw a RangeError exception.
- if (!::Locale::is_type_identifier(TRY(calendar.as_string().deprecated_string())))
+ if (!::Locale::is_type_identifier(TRY(calendar.as_string().utf8_string_view())))
return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, calendar, "calendar"sv);
// 8. Set opt.[[ca]] to calendar.
@@ -119,7 +119,7 @@ ThrowCompletionOr<DateTimeFormat*> initialize_date_time_format(VM& vm, DateTimeF
// 10. If numberingSystem is not undefined, then
if (!numbering_system.is_undefined()) {
// a. If numberingSystem does not match the Unicode Locale Identifier type nonterminal, throw a RangeError exception.
- if (!::Locale::is_type_identifier(TRY(numbering_system.as_string().deprecated_string())))
+ if (!::Locale::is_type_identifier(TRY(numbering_system.as_string().utf8_string_view())))
return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, numbering_system, "numberingSystem"sv);
// 11. Set opt.[[nu]] to numberingSystem.
@@ -277,7 +277,7 @@ ThrowCompletionOr<DateTimeFormat*> initialize_date_time_format(VM& vm, DateTimeF
// d. Set formatOptions.[[<prop>]] to value.
if (!value.is_undefined()) {
- option = ::Locale::calendar_pattern_style_from_string(TRY(value.as_string().deprecated_string()));
+ option = ::Locale::calendar_pattern_style_from_string(TRY(value.as_string().utf8_string_view()));
// e. If value is not undefined, then
// i. Set hasExplicitFormatComponents to true.
@@ -296,14 +296,14 @@ ThrowCompletionOr<DateTimeFormat*> initialize_date_time_format(VM& vm, DateTimeF
// 39. Set dateTimeFormat.[[DateStyle]] to dateStyle.
if (!date_style.is_undefined())
- date_time_format.set_date_style(TRY(date_style.as_string().deprecated_string()));
+ date_time_format.set_date_style(TRY(date_style.as_string().utf8_string_view()));
// 40. Let timeStyle be ? GetOption(options, "timeStyle", string, « "full", "long", "medium", "short" », undefined).
auto time_style = TRY(get_option(vm, *options, vm.names.timeStyle, OptionType::String, AK::Array { "full"sv, "long"sv, "medium"sv, "short"sv }, Empty {}));
// 41. Set dateTimeFormat.[[TimeStyle]] to timeStyle.
if (!time_style.is_undefined())
- date_time_format.set_time_style(TRY(time_style.as_string().deprecated_string()));
+ date_time_format.set_time_style(TRY(time_style.as_string().utf8_string_view()));
Optional<::Locale::CalendarPattern> best_format {};
@@ -325,7 +325,7 @@ ThrowCompletionOr<DateTimeFormat*> initialize_date_time_format(VM& vm, DateTimeF
auto formats = ::Locale::get_calendar_available_formats(data_locale, date_time_format.calendar());
// b. If matcher is "basic", then
- if (TRY(matcher.as_string().deprecated_string()) == "basic"sv) {
+ if (TRY(matcher.as_string().utf8_string_view()) == "basic"sv) {
// i. Let bestFormat be BasicFormatMatcher(formatOptions, formats).
best_format = basic_format_matcher(format_options, move(formats));
}
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp
index 9ec30d0333..d801b86a22 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp
@@ -82,7 +82,7 @@ ThrowCompletionOr<NonnullGCPtr<Object>> DisplayNamesConstructor::construct(Funct
auto style = TRY(get_option(vm, *options, vm.names.style, OptionType::String, { "narrow"sv, "short"sv, "long"sv }, "long"sv));
// 12. Set displayNames.[[Style]] to style.
- display_names->set_style(TRY(style.as_string().deprecated_string()));
+ display_names->set_style(TRY(style.as_string().utf8_string_view()));
// 13. Let type be ? GetOption(options, "type", string, « "language", "region", "script", "currency", "calendar", "dateTimeField" », undefined).
auto type = TRY(get_option(vm, *options, vm.names.type, OptionType::String, { "language"sv, "region"sv, "script"sv, "currency"sv, "calendar"sv, "dateTimeField"sv }, Empty {}));
@@ -92,13 +92,13 @@ ThrowCompletionOr<NonnullGCPtr<Object>> DisplayNamesConstructor::construct(Funct
return vm.throw_completion<TypeError>(ErrorType::IsUndefined, "options.type"sv);
// 15. Set displayNames.[[Type]] to type.
- display_names->set_type(TRY(type.as_string().deprecated_string()));
+ display_names->set_type(TRY(type.as_string().utf8_string_view()));
// 16. Let fallback be ? GetOption(options, "fallback", string, « "code", "none" », "code").
auto fallback = TRY(get_option(vm, *options, vm.names.fallback, OptionType::String, { "code"sv, "none"sv }, "code"sv));
// 17. Set displayNames.[[Fallback]] to fallback.
- display_names->set_fallback(TRY(fallback.as_string().deprecated_string()));
+ display_names->set_fallback(TRY(fallback.as_string().utf8_string_view()));
// 18. Set displayNames.[[Locale]] to r.[[locale]].
display_names->set_locale(move(result.locale));
@@ -119,7 +119,7 @@ ThrowCompletionOr<NonnullGCPtr<Object>> DisplayNamesConstructor::construct(Funct
// 26. If type is "language", then
if (display_names->type() == DisplayNames::Type::Language) {
// a. Set displayNames.[[LanguageDisplay]] to languageDisplay.
- display_names->set_language_display(TRY(language_display.as_string().deprecated_string()));
+ display_names->set_language_display(TRY(language_display.as_string().utf8_string_view()));
// b. Let typeFields be typeFields.[[<languageDisplay>]].
// c. Assert: typeFields is a Record (see 12.4.3).
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp
index f74b56ea99..409171838c 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp
@@ -43,11 +43,11 @@ JS_DEFINE_NATIVE_FUNCTION(DisplayNamesPrototype::of)
auto* display_names = TRY(typed_this_object(vm));
// 3. Let code be ? ToString(code).
- auto code_string = TRY(code.to_deprecated_string(vm));
- code = PrimitiveString::create(vm, move(code_string));
+ code = PrimitiveString::create(vm, TRY(code.to_string(vm)));
// 4. Let code be ? CanonicalCodeForDisplayNames(displayNames.[[Type]], code).
- code = TRY(canonical_code_for_display_names(vm, display_names->type(), TRY(code.as_string().deprecated_string())));
+ code = TRY(canonical_code_for_display_names(vm, display_names->type(), TRY(code.as_string().utf8_string_view())));
+ auto code_string = TRY(code.as_string().utf8_string_view());
// 5. Let fields be displayNames.[[Fields]].
// 6. If fields has a field [[<code>]], return fields.[[<code>]].
@@ -57,48 +57,48 @@ JS_DEFINE_NATIVE_FUNCTION(DisplayNamesPrototype::of)
switch (display_names->type()) {
case DisplayNames::Type::Language:
if (display_names->language_display() == DisplayNames::LanguageDisplay::Dialect) {
- result = ::Locale::get_locale_language_mapping(display_names->locale(), TRY(code.as_string().deprecated_string()));
+ result = ::Locale::get_locale_language_mapping(display_names->locale(), code_string);
if (result.has_value())
break;
}
- if (auto locale = is_structurally_valid_language_tag(TRY(code.as_string().deprecated_string())); locale.has_value())
+ if (auto locale = is_structurally_valid_language_tag(code_string); locale.has_value())
formatted_result = ::Locale::format_locale_for_display(display_names->locale(), locale.release_value());
break;
case DisplayNames::Type::Region:
- result = ::Locale::get_locale_territory_mapping(display_names->locale(), TRY(code.as_string().deprecated_string()));
+ result = ::Locale::get_locale_territory_mapping(display_names->locale(), code_string);
break;
case DisplayNames::Type::Script:
- result = ::Locale::get_locale_script_mapping(display_names->locale(), TRY(code.as_string().deprecated_string()));
+ result = ::Locale::get_locale_script_mapping(display_names->locale(), code_string);
break;
case DisplayNames::Type::Currency:
switch (display_names->style()) {
case ::Locale::Style::Long:
- result = ::Locale::get_locale_long_currency_mapping(display_names->locale(), TRY(code.as_string().deprecated_string()));
+ result = ::Locale::get_locale_long_currency_mapping(display_names->locale(), code_string);
break;
case ::Locale::Style::Short:
- result = ::Locale::get_locale_short_currency_mapping(display_names->locale(), TRY(code.as_string().deprecated_string()));
+ result = ::Locale::get_locale_short_currency_mapping(display_names->locale(), code_string);
break;
case ::Locale::Style::Narrow:
- result = ::Locale::get_locale_narrow_currency_mapping(display_names->locale(), TRY(code.as_string().deprecated_string()));
+ result = ::Locale::get_locale_narrow_currency_mapping(display_names->locale(), code_string);
break;
default:
VERIFY_NOT_REACHED();
}
break;
case DisplayNames::Type::Calendar:
- result = ::Locale::get_locale_calendar_mapping(display_names->locale(), TRY(code.as_string().deprecated_string()));
+ result = ::Locale::get_locale_calendar_mapping(display_names->locale(), code_string);
break;
case DisplayNames::Type::DateTimeField:
switch (display_names->style()) {
case ::Locale::Style::Long:
- result = ::Locale::get_locale_long_date_field_mapping(display_names->locale(), TRY(code.as_string().deprecated_string()));
+ result = ::Locale::get_locale_long_date_field_mapping(display_names->locale(), code_string);
break;
case ::Locale::Style::Short:
- result = ::Locale::get_locale_short_date_field_mapping(display_names->locale(), TRY(code.as_string().deprecated_string()));
+ result = ::Locale::get_locale_short_date_field_mapping(display_names->locale(), code_string);
break;
case ::Locale::Style::Narrow:
- result = ::Locale::get_locale_narrow_date_field_mapping(display_names->locale(), TRY(code.as_string().deprecated_string()));
+ result = ::Locale::get_locale_narrow_date_field_mapping(display_names->locale(), code_string);
break;
default:
VERIFY_NOT_REACHED();
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp
index 05a66798b7..b97d8fbca6 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp
@@ -276,7 +276,7 @@ ThrowCompletionOr<DurationUnitOptions> get_duration_unit_options(VM& vm, Depreca
// 2. Let displayDefault be "always".
auto display_default = "always"sv;
- DeprecatedString style;
+ StringView style;
// 3. If style is undefined, then
if (style_value.is_undefined()) {
@@ -308,7 +308,7 @@ ThrowCompletionOr<DurationUnitOptions> get_duration_unit_options(VM& vm, Depreca
}
}
} else {
- style = TRY(style_value.as_string().deprecated_string());
+ style = TRY(style_value.as_string().utf8_string_view());
}
// 4. Let displayField be the string-concatenation of unit and "Display".
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp
index 697a884167..1812372c81 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp
@@ -67,7 +67,7 @@ ThrowCompletionOr<NonnullGCPtr<Object>> DurationFormatConstructor::construct(Fun
// 7. If numberingSystem is not undefined, then
if (!numbering_system.is_undefined()) {
// a. If numberingSystem does not match the Unicode Locale Identifier type nonterminal, throw a RangeError exception.
- if (!::Locale::is_type_identifier(TRY(numbering_system.as_string().deprecated_string())))
+ if (!::Locale::is_type_identifier(TRY(numbering_system.as_string().utf8_string_view())))
return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, numbering_system, "numberingSystem"sv);
}
@@ -93,7 +93,7 @@ ThrowCompletionOr<NonnullGCPtr<Object>> DurationFormatConstructor::construct(Fun
auto style = TRY(get_option(vm, *options, vm.names.style, OptionType::String, { "long"sv, "short"sv, "narrow"sv, "digital"sv }, "short"sv));
// 14. Set durationFormat.[[Style]] to style.
- duration_format->set_style(TRY(style.as_string().deprecated_string()));
+ duration_format->set_style(TRY(style.as_string().utf8_string_view()));
// 15. Set durationFormat.[[DataLocale]] to r.[[dataLocale]].
duration_format->set_data_locale(move(result.data_locale));
@@ -119,7 +119,7 @@ ThrowCompletionOr<NonnullGCPtr<Object>> DurationFormatConstructor::construct(Fun
auto digital_base = duration_instances_component.digital_default;
// f. Let unitOptions be ? GetDurationUnitOptions(unit, options, style, valueList, digitalBase, prevStyle).
- auto unit_options = TRY(get_duration_unit_options(vm, unit, *options, TRY(style.as_string().deprecated_string()), value_list, digital_base, previous_style));
+ auto unit_options = TRY(get_duration_unit_options(vm, unit, *options, TRY(style.as_string().utf8_string_view()), value_list, digital_base, previous_style));
// g. Set the value of the styleSlot slot of durationFormat to unitOptions.[[Style]].
(duration_format->*style_slot)(unit_options.style);
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/Intl.cpp b/Userland/Libraries/LibJS/Runtime/Intl/Intl.cpp
index 228a44e980..b9787f157e 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/Intl.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/Intl.cpp
@@ -111,7 +111,7 @@ JS_DEFINE_NATIVE_FUNCTION(Intl::supported_values_of)
auto& realm = *vm.current_realm();
// 1. Let key be ? ToString(key).
- auto key = TRY(vm.argument(0).to_deprecated_string(vm));
+ auto key = TRY(vm.argument(0).to_string(vm));
Span<StringView const> list;
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp
index d3e8d58858..2708455d26 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp
@@ -80,13 +80,13 @@ ThrowCompletionOr<NonnullGCPtr<Object>> ListFormatConstructor::construct(Functio
auto type = TRY(get_option(vm, *options, vm.names.type, OptionType::String, { "conjunction"sv, "disjunction"sv, "unit"sv }, "conjunction"sv));
// 12. Set listFormat.[[Type]] to type.
- list_format->set_type(TRY(type.as_string().deprecated_string()));
+ list_format->set_type(TRY(type.as_string().utf8_string_view()));
// 13. Let style be ? GetOption(options, "style", string, « "long", "short", "narrow" », "long").
auto style = TRY(get_option(vm, *options, vm.names.style, OptionType::String, { "long"sv, "short"sv, "narrow"sv }, "long"sv));
// 14. Set listFormat.[[Style]] to style.
- list_format->set_style(TRY(style.as_string().deprecated_string()));
+ list_format->set_style(TRY(style.as_string().utf8_string_view()));
// Note: The remaining steps are skipped in favor of deferring to LibUnicode.
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp
index be16b88191..307b64b98e 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp
@@ -33,7 +33,7 @@ static ThrowCompletionOr<Optional<DeprecatedString>> get_string_option(VM& vm, O
if (option.is_undefined())
return Optional<DeprecatedString> {};
- if (validator && !validator(TRY(option.as_string().deprecated_string())))
+ if (validator && !validator(TRY(option.as_string().utf8_string_view())))
return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, option, property);
return TRY(option.as_string().deprecated_string());
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.cpp
index 4c85ecb660..fd50f1fa16 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.cpp
@@ -115,7 +115,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::base_name)
VERIFY(locale.has_value());
// 4. Return the substring of locale corresponding to the unicode_language_id production.
- return PrimitiveString::create(vm, locale->language_id.to_deprecated_string());
+ return PrimitiveString::create(vm, TRY_OR_THROW_OOM(vm, locale->language_id.to_string()));
}
#define JS_ENUMERATE_LOCALE_KEYWORD_PROPERTIES \
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.cpp
index dec7303d13..fb7a41809a 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.cpp
@@ -103,7 +103,7 @@ ThrowCompletionOr<NumberFormat*> initialize_number_format(VM& vm, NumberFormat&
// 7. If numberingSystem is not undefined, then
if (!numbering_system.is_undefined()) {
// a. If numberingSystem does not match the Unicode Locale Identifier type nonterminal, throw a RangeError exception.
- if (!::Locale::is_type_identifier(TRY(numbering_system.as_string().deprecated_string())))
+ if (!::Locale::is_type_identifier(TRY(numbering_system.as_string().utf8_string_view())))
return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, numbering_system, "numberingSystem"sv);
// 8. Set opt.[[nu]] to numberingSystem.
@@ -176,7 +176,7 @@ ThrowCompletionOr<NumberFormat*> initialize_number_format(VM& vm, NumberFormat&
auto notation = TRY(get_option(vm, *options, vm.names.notation, OptionType::String, { "standard"sv, "scientific"sv, "engineering"sv, "compact"sv }, "standard"sv));
// 22. Set numberFormat.[[Notation]] to notation.
- number_format.set_notation(TRY(notation.as_string().deprecated_string()));
+ number_format.set_notation(TRY(notation.as_string().utf8_string_view()));
// 23. Perform ? SetNumberFormatDigitOptions(numberFormat, options, mnfdDefault, mxfdDefault, notation).
TRY(set_number_format_digit_options(vm, number_format, *options, default_min_fraction_digits, default_max_fraction_digits, number_format.notation()));
@@ -199,7 +199,7 @@ ThrowCompletionOr<NumberFormat*> initialize_number_format(VM& vm, NumberFormat&
auto trailing_zero_display = TRY(get_option(vm, *options, vm.names.trailingZeroDisplay, OptionType::String, { "auto"sv, "stripIfInteger"sv }, "auto"sv));
// 27. Set numberFormat.[[TrailingZeroDisplay]] to trailingZeroDisplay.
- number_format.set_trailing_zero_display(TRY(trailing_zero_display.as_string().deprecated_string()));
+ number_format.set_trailing_zero_display(TRY(trailing_zero_display.as_string().utf8_string_view()));
// 28. Let compactDisplay be ? GetOption(options, "compactDisplay", string, « "short", "long" », "short").
auto compact_display = TRY(get_option(vm, *options, vm.names.compactDisplay, OptionType::String, { "short"sv, "long"sv }, "short"sv));
@@ -210,7 +210,7 @@ ThrowCompletionOr<NumberFormat*> initialize_number_format(VM& vm, NumberFormat&
// 30. If notation is "compact", then
if (number_format.notation() == NumberFormat::Notation::Compact) {
// a. Set numberFormat.[[CompactDisplay]] to compactDisplay.
- number_format.set_compact_display(TRY(compact_display.as_string().deprecated_string()));
+ number_format.set_compact_display(TRY(compact_display.as_string().utf8_string_view()));
// b. Set defaultUseGrouping to "min2".
default_use_grouping = "min2"sv;
@@ -226,13 +226,13 @@ ThrowCompletionOr<NumberFormat*> initialize_number_format(VM& vm, NumberFormat&
auto sign_display = TRY(get_option(vm, *options, vm.names.signDisplay, OptionType::String, { "auto"sv, "never"sv, "always"sv, "exceptZero"sv, "negative"sv }, "auto"sv));
// 34. Set numberFormat.[[SignDisplay]] to signDisplay.
- number_format.set_sign_display(TRY(sign_display.as_string().deprecated_string()));
+ number_format.set_sign_display(TRY(sign_display.as_string().utf8_string_view()));
// 35. Let roundingMode be ? GetOption(options, "roundingMode", string, « "ceil", "floor", "expand", "trunc", "halfCeil", "halfFloor", "halfExpand", "halfTrunc", "halfEven" », "halfExpand").
auto rounding_mode = TRY(get_option(vm, *options, vm.names.roundingMode, OptionType::String, { "ceil"sv, "floor"sv, "expand"sv, "trunc"sv, "halfCeil"sv, "halfFloor"sv, "halfExpand"sv, "halfTrunc"sv, "halfEven"sv }, "halfExpand"sv));
// 36. Set numberFormat.[[RoundingMode]] to roundingMode.
- number_format.set_rounding_mode(TRY(rounding_mode.as_string().deprecated_string()));
+ number_format.set_rounding_mode(TRY(rounding_mode.as_string().utf8_string_view()));
// 37. Return numberFormat.
return &number_format;
@@ -282,7 +282,7 @@ ThrowCompletionOr<void> set_number_format_digit_options(VM& vm, NumberFormatBase
bool need_fraction_digits = true;
// 14. If roundingPriority is "auto", then
- if (TRY(rounding_priority.as_string().deprecated_string()) == "auto"sv) {
+ if (TRY(rounding_priority.as_string().utf8_string_view()) == "auto"sv) {
// a. Set needSd to hasSd.
need_significant_digits = has_significant_digits;
@@ -357,13 +357,15 @@ ThrowCompletionOr<void> set_number_format_digit_options(VM& vm, NumberFormatBase
// 17. If needSd is true or needFd is true, then
if (need_significant_digits || need_fraction_digits) {
+ auto rounding_priority_string = TRY(rounding_priority.as_string().utf8_string_view());
+
// a. If roundingPriority is "morePrecision", then
- if (TRY(rounding_priority.as_string().deprecated_string()) == "morePrecision"sv) {
+ if (rounding_priority_string == "morePrecision"sv) {
// i. Set intlObj.[[RoundingType]] to morePrecision.
intl_object.set_rounding_type(NumberFormatBase::RoundingType::MorePrecision);
}
// b. Else if roundingPriority is "lessPrecision", then
- else if (TRY(rounding_priority.as_string().deprecated_string()) == "lessPrecision"sv) {
+ else if (rounding_priority_string == "lessPrecision"sv) {
// i. Set intlObj.[[RoundingType]] to lessPrecision.
intl_object.set_rounding_type(NumberFormatBase::RoundingType::LessPrecision);
}
@@ -410,7 +412,7 @@ ThrowCompletionOr<void> set_number_format_unit_options(VM& vm, NumberFormat& int
auto style = TRY(get_option(vm, options, vm.names.style, OptionType::String, { "decimal"sv, "percent"sv, "currency"sv, "unit"sv }, "decimal"sv));
// 4. Set intlObj.[[Style]] to style.
- intl_object.set_style(TRY(style.as_string().deprecated_string()));
+ intl_object.set_style(TRY(style.as_string().utf8_string_view()));
// 5. Let currency be ? GetOption(options, "currency", string, empty, undefined).
auto currency = TRY(get_option(vm, options, vm.names.currency, OptionType::String, {}, Empty {}));
@@ -423,7 +425,7 @@ ThrowCompletionOr<void> set_number_format_unit_options(VM& vm, NumberFormat& int
}
// 7. Else,
// a. If ! IsWellFormedCurrencyCode(currency) is false, throw a RangeError exception.
- else if (!is_well_formed_currency_code(TRY(currency.as_string().deprecated_string())))
+ else if (!is_well_formed_currency_code(TRY(currency.as_string().utf8_string_view())))
return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, currency, "currency"sv);
// 8. Let currencyDisplay be ? GetOption(options, "currencyDisplay", string, « "code", "symbol", "narrowSymbol", "name" », "symbol").
@@ -443,7 +445,7 @@ ThrowCompletionOr<void> set_number_format_unit_options(VM& vm, NumberFormat& int
}
// 12. Else,
// a. If ! IsWellFormedUnitIdentifier(unit) is false, throw a RangeError exception.
- else if (!is_well_formed_unit_identifier(TRY(unit.as_string().deprecated_string())))
+ else if (!is_well_formed_unit_identifier(TRY(unit.as_string().utf8_string_view())))
return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, unit, "unit"sv);
// 13. Let unitDisplay be ? GetOption(options, "unitDisplay", string, « "short", "narrow", "long" », "short").
@@ -455,19 +457,19 @@ ThrowCompletionOr<void> set_number_format_unit_options(VM& vm, NumberFormat& int
intl_object.set_currency(TRY(currency.as_string().deprecated_string()).to_uppercase());
// c. Set intlObj.[[CurrencyDisplay]] to currencyDisplay.
- intl_object.set_currency_display(TRY(currency_display.as_string().deprecated_string()));
+ intl_object.set_currency_display(TRY(currency_display.as_string().utf8_string_view()));
// d. Set intlObj.[[CurrencySign]] to currencySign.
- intl_object.set_currency_sign(TRY(currency_sign.as_string().deprecated_string()));
+ intl_object.set_currency_sign(TRY(currency_sign.as_string().utf8_string_view()));
}
// 15. If style is "unit", then
if (intl_object.style() == NumberFormat::Style::Unit) {
// a. Set intlObj.[[Unit]] to unit.
- intl_object.set_unit(TRY(unit.as_string().deprecated_string()));
+ intl_object.set_unit(TRY(unit.as_string().utf8_string_view()));
// b. Set intlObj.[[UnitDisplay]] to unitDisplay.
- intl_object.set_unit_display(TRY(unit_display.as_string().deprecated_string()));
+ intl_object.set_unit_display(TRY(unit_display.as_string().utf8_string_view()));
}
return {};
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.cpp
index 869fedd2cb..9a59f73d51 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.cpp
@@ -94,7 +94,7 @@ ThrowCompletionOr<PluralRules*> initialize_plural_rules(VM& vm, PluralRules& plu
auto type = TRY(get_option(vm, *options, vm.names.type, OptionType::String, AK::Array { "cardinal"sv, "ordinal"sv }, "cardinal"sv));
// 7. Set pluralRules.[[Type]] to t.
- plural_rules.set_type(TRY(type.as_string().deprecated_string()));
+ plural_rules.set_type(TRY(type.as_string().utf8_string_view()));
// 8. Perform ? SetNumberFormatDigitOptions(pluralRules, options, +0𝔽, 3𝔽, "standard").
TRY(set_number_format_digit_options(vm, plural_rules, *options, 0, 3, NumberFormat::Notation::Standard));
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormat.cpp b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormat.cpp
index cf03c028b0..1dce1620b0 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormat.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormat.cpp
@@ -141,7 +141,7 @@ ThrowCompletionOr<Vector<PatternPartitionWithUnit>> partition_relative_time_patt
// 16. If numeric is equal to "auto", then
if (relative_time_format.numeric() == RelativeTimeFormat::Numeric::Auto) {
// a. Let valueString be ToString(value).
- auto value_string = MUST(Value(value).to_deprecated_string(vm));
+ auto value_string = MUST(Value(value).to_string(vm));
// b. If patterns has a field [[<valueString>]], then
if (auto patterns = find_patterns_for_tense_or_number(value_string); !patterns.is_empty()) {
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.cpp
index 99cd3e9e65..08a9d7db91 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.cpp
@@ -101,7 +101,7 @@ ThrowCompletionOr<RelativeTimeFormat*> initialize_relative_time_format(VM& vm, R
// 7. If numberingSystem is not undefined, then
if (!numbering_system.is_undefined()) {
// a. If numberingSystem does not match the Unicode Locale Identifier type nonterminal, throw a RangeError exception.
- if (!::Locale::is_type_identifier(TRY(numbering_system.as_string().deprecated_string())))
+ if (!::Locale::is_type_identifier(TRY(numbering_system.as_string().utf8_string_view())))
return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, numbering_system, "numberingSystem"sv);
// 8. Set opt.[[nu]] to numberingSystem.
@@ -129,13 +129,13 @@ ThrowCompletionOr<RelativeTimeFormat*> initialize_relative_time_format(VM& vm, R
auto style = TRY(get_option(vm, *options, vm.names.style, OptionType::String, { "long"sv, "short"sv, "narrow"sv }, "long"sv));
// 16. Set relativeTimeFormat.[[Style]] to style.
- relative_time_format.set_style(TRY(style.as_string().deprecated_string()));
+ relative_time_format.set_style(TRY(style.as_string().utf8_string_view()));
// 17. Let numeric be ? GetOption(options, "numeric", string, « "always", "auto" », "always").
auto numeric = TRY(get_option(vm, *options, vm.names.numeric, OptionType::String, { "always"sv, "auto"sv }, "always"sv));
// 18. Set relativeTimeFormat.[[Numeric]] to numeric.
- relative_time_format.set_numeric(TRY(numeric.as_string().deprecated_string()));
+ relative_time_format.set_numeric(TRY(numeric.as_string().utf8_string_view()));
// 19. Let relativeTimeFormat.[[NumberFormat]] be ! Construct(%NumberFormat%, « locale »).
auto number_format = MUST(construct(vm, *realm.intrinsics().intl_number_format_constructor(), PrimitiveString::create(vm, locale)));
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatPrototype.cpp
index 1dc8bfc32d..44478487d2 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatPrototype.cpp
@@ -42,10 +42,10 @@ JS_DEFINE_NATIVE_FUNCTION(RelativeTimeFormatPrototype::format)
auto value = TRY(vm.argument(0).to_number(vm));
// 4. Let unit be ? ToString(unit).
- auto unit = TRY(vm.argument(1).to_deprecated_string(vm));
+ auto unit = TRY(vm.argument(1).to_string(vm));
// 5. Return ? FormatRelativeTime(relativeTimeFormat, value, unit).
- auto formatted = TRY(format_relative_time(vm, *relative_time_format, value.as_double(), unit));
+ auto formatted = TRY(format_relative_time(vm, *relative_time_format, value.as_double(), unit.bytes_as_string_view()));
return PrimitiveString::create(vm, move(formatted));
}
@@ -60,10 +60,10 @@ JS_DEFINE_NATIVE_FUNCTION(RelativeTimeFormatPrototype::format_to_parts)
auto value = TRY(vm.argument(0).to_number(vm));
// 4. Let unit be ? ToString(unit).
- auto unit = TRY(vm.argument(1).to_deprecated_string(vm));
+ auto unit = TRY(vm.argument(1).to_string(vm));
// 5. Return ? FormatRelativeTimeToParts(relativeTimeFormat, value, unit).
- return TRY(format_relative_time_to_parts(vm, *relative_time_format, value.as_double(), unit));
+ return TRY(format_relative_time_to_parts(vm, *relative_time_format, value.as_double(), unit.bytes_as_string_view()));
}
// 17.3.5 Intl.RelativeTimeFormat.prototype.resolvedOptions ( ), https://tc39.es/ecma402/#sec-intl.relativetimeformat.prototype.resolvedoptions
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.cpp
index 373afae02c..0141b268ee 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.cpp
@@ -81,7 +81,7 @@ ThrowCompletionOr<NonnullGCPtr<Object>> SegmenterConstructor::construct(Function
auto granularity = TRY(get_option(vm, *options, vm.names.granularity, OptionType::String, { "grapheme"sv, "word"sv, "sentence"sv }, "grapheme"sv));
// 13. Set segmenter.[[SegmenterGranularity]] to granularity.
- segmenter->set_segmenter_granularity(TRY(granularity.as_string().deprecated_string()));
+ segmenter->set_segmenter_granularity(TRY(granularity.as_string().utf8_string_view()));
// 14. Return segmenter.
return segmenter;