mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 05:20:30 +00:00
LibTextCodec: Normalize incoming encodings in decoder_for()
Instead of asserting when you call TextCoded::decoder_for() with a non-standard encoding name, let's be nice and see if we can't find a decoder for the standardized version of the encoding name.
This commit is contained in:
parent
986ce57be9
commit
024059b49b
Notes:
sideshowbarker
2024-07-19 00:53:26 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/024059b49b0
1 changed files with 3 additions and 3 deletions
|
@ -46,14 +46,14 @@ static UTF8Decoder& utf8_decoder()
|
|||
return *decoder;
|
||||
}
|
||||
|
||||
Decoder* decoder_for(const String& encoding)
|
||||
Decoder* decoder_for(const String& a_encoding)
|
||||
{
|
||||
ASSERT(is_standardized_encoding(encoding));
|
||||
auto encoding = get_standardized_encoding(a_encoding);
|
||||
if (encoding.equals_ignoring_case("windows-1252"))
|
||||
return &latin1_decoder();
|
||||
if (encoding.equals_ignoring_case("utf-8"))
|
||||
return &utf8_decoder();
|
||||
dbg() << "TextCodec: No decoder implemented for encoding '" << encoding << "'";
|
||||
dbgln("TextCodec: No decoder implemented for encoding '{}'", a_encoding);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue