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

LibTextCodec+Everywhere: Return Optional<Decoder&> from decoder_for()

This commit is contained in:
Sam Atkins 2023-02-17 17:45:08 +00:00 committed by Andreas Kling
parent 2f4c463920
commit f2a9426885
16 changed files with 42 additions and 39 deletions

View file

@ -219,10 +219,10 @@ DeprecatedString XMLHttpRequest::get_text_response() const
charset = "UTF-8"sv;
// 5. Return the result of running decode on xhrs received bytes using fallback encoding charset.
auto* decoder = TextCodec::decoder_for(charset.value());
auto decoder = TextCodec::decoder_for(charset.value());
// If we don't support the decoder yet, let's crash instead of attempting to return something, as the result would be incorrect and create obscure bugs.
VERIFY(decoder);
VERIFY(decoder.has_value());
return TextCodec::convert_input_to_utf8_using_given_decoder_unless_there_is_a_byte_order_mark(*decoder, m_received_bytes);
}