1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 05:48:12 +00:00

LibJS: Add FIXMEs to a few functions that need UTF-16 handling

This commit is contained in:
Nico Weber 2020-07-22 09:56:38 -04:00 committed by Andreas Kling
parent 979e02c0a8
commit 248b79d687
2 changed files with 8 additions and 1 deletions

View file

@ -251,6 +251,7 @@ JS_DEFINE_NATIVE_FUNCTION(WindowObject::atob)
auto string = interpreter.argument(0).to_string(interpreter);
if (interpreter.exception())
return {};
// FIXME: This should convert string from a byte string to LibJS's internal string encoding (UTF-8).
auto decoded = decode_base64(StringView(string));
return JS::js_string(interpreter, String::copy(decoded));
}
@ -265,6 +266,7 @@ JS_DEFINE_NATIVE_FUNCTION(WindowObject::btoa)
auto string = interpreter.argument(0).to_string(interpreter);
if (interpreter.exception())
return {};
// FIXME: This should convert string to a non-UTF-8 byte string first.
auto encoded = encode_base64(StringView(string));
return JS::js_string(interpreter, String::copy(encoded));
}