mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-25 19:04:58 +00:00
LibWeb/FileAPI: Implement FileReader readAsBinaryString
This commit is contained in:
committed by
Sam Atkins
parent
d79bb1aac2
commit
eca68aad88
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user