1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:17:36 +00:00

LibTextCodec+Everywhere: Make TextCodec::decoder_for() take a StringView

We don't need a full String/DeprecatedString inside this function, so we
might as well not force users to create one.
This commit is contained in:
Sam Atkins 2023-02-13 17:23:31 +00:00 committed by Tim Flynn
parent 3c8bfa4662
commit d6075ef5b5
14 changed files with 16 additions and 16 deletions

View file

@ -267,7 +267,7 @@ NonnullRefPtr<StringObject> Parser::parse_string()
if (unencrypted_string.bytes().starts_with(Array<u8, 2> { 0xfe, 0xff })) {
// The string is encoded in UTF16-BE
string_object->set_string(TextCodec::decoder_for("utf-16be")->to_utf8(unencrypted_string));
string_object->set_string(TextCodec::decoder_for("utf-16be"sv)->to_utf8(unencrypted_string));
} else if (unencrypted_string.bytes().starts_with(Array<u8, 3> { 239, 187, 191 })) {
// The string is encoded in UTF-8. This is the default anyways, but if these bytes
// are explicitly included, we have to trim them