mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 05:08:13 +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
1 changed files with 3 additions and 3 deletions
|
@ -46,14 +46,14 @@ static UTF8Decoder& utf8_decoder()
|
||||||
return *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"))
|
if (encoding.equals_ignoring_case("windows-1252"))
|
||||||
return &latin1_decoder();
|
return &latin1_decoder();
|
||||||
if (encoding.equals_ignoring_case("utf-8"))
|
if (encoding.equals_ignoring_case("utf-8"))
|
||||||
return &utf8_decoder();
|
return &utf8_decoder();
|
||||||
dbg() << "TextCodec: No decoder implemented for encoding '" << encoding << "'";
|
dbgln("TextCodec: No decoder implemented for encoding '{}'", a_encoding);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue