AK: Add String::from_utf8_with_replacement_character

This takes a byte sequence and converts it to a UTF-8 string with the
replacement character.
This commit is contained in:
Shannon Booth 2024-08-10 17:16:01 +12:00 committed by Andreas Kling
commit 033ea0e7fb
Notes: github-actions[bot] 2024-08-10 08:47:28 +00:00
3 changed files with 26 additions and 0 deletions

View file

@ -20,6 +20,16 @@
namespace AK {
String String::from_utf8_with_replacement_character(StringView view)
{
StringBuilder builder;
for (auto c : Utf8View { view })
builder.append_code_point(c);
return builder.to_string_without_validation();
}
String String::from_utf8_without_validation(ReadonlyBytes bytes)
{
String result;