#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "third_party/blink/renderer/platform/wtf/text/text_codec_cjk.h"
#include <utility>
#include "base/feature_list.h"
#include "base/functional/function_ref.h"
#include "base/memory/ptr_util.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/renderer/platform/wtf/text/character_names.h"
#include "third_party/blink/renderer/platform/wtf/text/encoding_tables.h"
#include "third_party/blink/renderer/platform/wtf/text/string_concatenate.h"
#include "third_party/blink/renderer/platform/wtf/text/text_encoding.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
namespace WTF {
class TextCodecCJK::Decoder { … };
namespace {
constexpr char kCanonicalNameEucJp[] = …;
constexpr char kCanonicalNameShiftJis[] = …;
constexpr char kCanonicalNameEucKr[] = …;
constexpr char kCanonicalNameIso2022Jp[] = …;
constexpr char kCanonicalNameGbk[] = …;
constexpr char kCanonicalNameGb18030[] = …;
constexpr std::array<const char*, 6> kSupportedCanonicalNames{ … };
void AppendUnencodableReplacement(UChar32 code_point,
UnencodableHandling handling,
Vector<uint8_t>& result) { … }
std::optional<UChar> FindCodePointInJis0208(uint16_t pointer) { … }
std::optional<UChar> FindCodePointJis0212(uint16_t pointer) { … }
Vector<uint8_t> EncodeEucJp(StringView string, UnencodableHandling handling) { … }
class Iso2022JpEncoder { … };
Vector<uint8_t> EncodeIso2022Jp(StringView string,
UnencodableHandling handling) { … }
Vector<uint8_t> EncodeShiftJis(StringView string,
UnencodableHandling handling) { … }
Vector<uint8_t> EncodeEucKr(StringView string, UnencodableHandling handling) { … }
const std::array<std::pair<uint32_t, UChar32>, 207>& Gb18030Ranges() { … }
std::optional<UChar32> IndexGb18030RangesCodePoint(uint32_t pointer) { … }
uint32_t Gb18030RangesPointer(UChar32 code_point) { … }
static std::optional<uint32_t> Gb18030_2022Encode(UChar32 codePoint) { … }
static std::optional<UChar32> Gb18030_2022Decode(uint8_t first,
uint8_t second,
uint8_t third,
uint8_t fourth) { … }
enum class IsGbk : bool { … };
Vector<uint8_t> EncodeGbShared(StringView string,
UnencodableHandling handling,
IsGbk is_gbk) { … }
Vector<uint8_t> EncodeGb18030(StringView string, UnencodableHandling handling) { … }
Vector<uint8_t> EncodeGbk(StringView string, UnencodableHandling handling) { … }
class EucJpDecoder : public TextCodecCJK::Decoder { … };
class Iso2022JpDecoder : public TextCodecCJK::Decoder { … };
class ShiftJisDecoder : public TextCodecCJK::Decoder { … };
class EucKrDecoder : public TextCodecCJK::Decoder { … };
class Gb18030Decoder : public TextCodecCJK::Decoder { … };
}
enum class TextCodecCJK::Encoding : uint8_t { … };
TextCodecCJK::TextCodecCJK(Encoding encoding) : … { … }
void TextCodecCJK::RegisterEncodingNames(EncodingNameRegistrar registrar) { … }
void TextCodecCJK::RegisterCodecs(TextCodecRegistrar registrar) { … }
std::unique_ptr<TextCodec> TextCodecCJK::Create(const TextEncoding& encoding,
const void*) { … }
String TextCodecCJK::Decoder::Decode(const uint8_t* bytes,
wtf_size_t length,
bool flush,
bool stop_on_error,
bool& saw_error) { … }
String TextCodecCJK::Decode(const char* charBytes,
wtf_size_t length,
FlushBehavior flush_behavior,
bool stop_on_error,
bool& saw_error) { … }
Vector<uint8_t> TextCodecCJK::EncodeCommon(StringView string,
UnencodableHandling handling) const { … }
std::string TextCodecCJK::Encode(const UChar* characters,
wtf_size_t length,
UnencodableHandling handling) { … }
std::string TextCodecCJK::Encode(const LChar* characters,
wtf_size_t length,
UnencodableHandling handling) { … }
bool TextCodecCJK::IsSupported(StringView name) { … }
}