AK+LibJS+LibWeb+LibRegex: Replace AK::Utf16Data with AK::Utf16String

This commit is contained in:
Timothy Flynn 2025-07-09 14:13:38 -04:00 committed by Tim Flynn
commit 9582895759
Notes: github-actions[bot] 2025-07-18 16:46:53 +00:00
22 changed files with 101 additions and 222 deletions

View file

@ -106,11 +106,10 @@ WebIDL::ExceptionOr<FileReader::Result> FileReader::blob_package_data(JS::Realm&
return JS::ArrayBuffer::create(realm, move(bytes));
case Type::BinaryString:
// Return bytes as a binary string, in which every byte is represented by a code unit of equal value [0..255].
Utf16Data builder;
builder.ensure_capacity(bytes.size());
StringBuilder builder(StringBuilder::Mode::UTF16, bytes.size());
for (auto byte : bytes.bytes())
builder.unchecked_append(byte);
return MUST(Utf16View { builder }.to_utf8());
builder.append_code_unit(byte);
return MUST(builder.utf16_string_view().to_utf8());
}
VERIFY_NOT_REACHED();
}