Add explicit IgnoreBOM and ErrorMode options to LibTextCodec decoders, and thread them through TextDecoder and TextDecoderStream. This lets Web-facing decoder APIs preserve BOMs when requested and use fatal error handling without post-processing decoded output. NB: RemoveBOM was renamed to IgnoreBOM as "RemoveBOM" is the name used by encoding_rs and was previously an implementation detail. The new name matches what is used by the encoding standard as it is now also used in LibWeb.
21 lines
518 B
C++
21 lines
518 B
C++
/*
|
|
* Copyright (c) 2026-present, the Ladybird developers.
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <LibWeb/Encoding/TextDecoderCommon.h>
|
|
|
|
namespace Web::Encoding {
|
|
|
|
TextDecoderCommonMixin::TextDecoderCommonMixin(TextCodec::Decoder& decoder, FlyString encoding, TextCodec::ErrorMode error_mode, bool ignore_bom)
|
|
: m_decoder(decoder)
|
|
, m_encoding(move(encoding))
|
|
, m_error_mode(error_mode)
|
|
, m_ignore_bom(ignore_bom)
|
|
{
|
|
}
|
|
|
|
TextDecoderCommonMixin::~TextDecoderCommonMixin() = default;
|
|
|
|
}
|