mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 08:54:58 +00:00
AK: Add Utf16View::to_utf8 to convert the view to a UTF-8 AK::String
This commit is contained in:
parent
d0403ec14f
commit
2eacc7aec1
3 changed files with 17 additions and 10 deletions
|
@ -82,6 +82,11 @@ u32 Utf16View::decode_surrogate_pair(u16 high_surrogate, u16 low_surrogate)
|
|||
}
|
||||
|
||||
ErrorOr<DeprecatedString> Utf16View::to_deprecated_string(AllowInvalidCodeUnits allow_invalid_code_units) const
|
||||
{
|
||||
return TRY(to_utf8(allow_invalid_code_units)).to_deprecated_string();
|
||||
}
|
||||
|
||||
ErrorOr<String> Utf16View::to_utf8(AllowInvalidCodeUnits allow_invalid_code_units) const
|
||||
{
|
||||
StringBuilder builder;
|
||||
|
||||
|
@ -105,7 +110,7 @@ ErrorOr<DeprecatedString> Utf16View::to_deprecated_string(AllowInvalidCodeUnits
|
|||
TRY(builder.try_append_code_point(code_point));
|
||||
}
|
||||
|
||||
return builder.build();
|
||||
return builder.to_string();
|
||||
}
|
||||
|
||||
size_t Utf16View::length_in_code_points() const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue