1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 09:14:58 +00:00

LibJS: Define Utf16String::to_utf8 to convert Utf16String to String

This commit is contained in:
Timothy Flynn 2023-01-13 12:19:45 -05:00 committed by Linus Groh
parent 4eb5eb2080
commit c79d20be58
2 changed files with 6 additions and 0 deletions

View file

@ -102,6 +102,11 @@ Utf16View Utf16String::substring_view(size_t code_unit_offset) const
return view().substring_view(code_unit_offset);
}
ThrowCompletionOr<String> Utf16String::to_utf8(VM& vm) const
{
return TRY_OR_THROW_OOM(vm, view().to_utf8(Utf16View::AllowInvalidCodeUnits::Yes));
}
ThrowCompletionOr<DeprecatedString> Utf16String::to_deprecated_string(VM& vm) const
{
return TRY_OR_THROW_OOM(vm, view().to_deprecated_string(Utf16View::AllowInvalidCodeUnits::Yes));

View file

@ -50,6 +50,7 @@ public:
Utf16View substring_view(size_t code_unit_offset, size_t code_unit_length) const;
Utf16View substring_view(size_t code_unit_offset) const;
ThrowCompletionOr<String> to_utf8(VM&) const;
ThrowCompletionOr<DeprecatedString> to_deprecated_string(VM&) const;
u16 code_unit_at(size_t index) const;