mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-03 09:48:47 +00:00
LibWeb/FileAPI: Implement FileReader readAsBinaryString
This commit is contained in:
parent
d79bb1aac2
commit
eca68aad88
Notes:
github-actions[bot]
2025-01-28 11:40:38 +00:00
Author: https://github.com/shannonbooth
Commit: eca68aad88
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3343
Reviewed-by: https://github.com/AtkinsSJ ✅
4 changed files with 50 additions and 2 deletions
|
@ -105,8 +105,12 @@ WebIDL::ExceptionOr<FileReader::Result> FileReader::blob_package_data(JS::Realm&
|
|||
// Return a new ArrayBuffer whose contents are bytes.
|
||||
return JS::ArrayBuffer::create(realm, move(bytes));
|
||||
case Type::BinaryString:
|
||||
// FIXME: Return bytes as a binary string, in which every byte is represented by a code unit of equal value [0..255].
|
||||
return WebIDL::NotSupportedError::create(realm, "BinaryString not supported yet"_string);
|
||||
// Return bytes as a binary string, in which every byte is represented by a code unit of equal value [0..255].
|
||||
Vector<u16> builder;
|
||||
builder.ensure_capacity(bytes.size());
|
||||
for (auto byte : bytes.bytes())
|
||||
builder.unchecked_append(byte);
|
||||
return MUST(Utf16View { builder }.to_utf8(Utf16View::AllowInvalidCodeUnits::Yes));
|
||||
}
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue