1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-04 12:07:35 +00:00

LibWeb: Use standardized encoding names, add encoding attribute to document

This commit is contained in:
Luke 2020-11-13 11:16:28 +00:00 committed by Andreas Kling
parent f3d2053bff
commit ed2689c00a
5 changed files with 20 additions and 5 deletions

View file

@ -283,7 +283,9 @@ JS_DEFINE_NATIVE_FUNCTION(WindowObject::atob)
auto decoded = decode_base64(StringView(string));
// decode_base64() returns a byte string. LibJS uses UTF-8 for strings. Use Latin1Decoder to convert bytes 128-255 to UTF-8.
return JS::js_string(vm, TextCodec::decoder_for("iso-8859-1")->to_utf8(decoded));
auto decoder = TextCodec::decoder_for("windows-1252");
ASSERT(decoder);
return JS::js_string(vm, decoder->to_utf8(decoded));
}
JS_DEFINE_NATIVE_FUNCTION(WindowObject::btoa)