#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "third_party/blink/renderer/platform/wtf/text/text_codec_utf8.h"
#include <memory>
#include <variant>
#include "base/memory/ptr_util.h"
#include "base/numerics/checked_math.h"
#include "third_party/blink/renderer/platform/wtf/text/character_names.h"
#include "third_party/blink/renderer/platform/wtf/text/string_buffer.h"
#include "third_party/blink/renderer/platform/wtf/text/text_codec_ascii_fast_path.h"
namespace WTF {
const int kNonCharacter1 = …;
const int kNonCharacter2 = …;
const int kNonCharacter3 = …;
bool IsNonCharacter(int character) { … }
std::unique_ptr<TextCodec> TextCodecUTF8::Create(const TextEncoding&,
const void*) { … }
void TextCodecUTF8::RegisterEncodingNames(EncodingNameRegistrar registrar) { … }
void TextCodecUTF8::RegisterCodecs(TextCodecRegistrar registrar) { … }
static constexpr uint8_t kNonASCIISequenceLength[256] = …;
static inline int DecodeNonASCIISequence(const uint8_t* sequence,
unsigned length) { … }
static inline UChar* AppendCharacter(UChar* destination, int character) { … }
void TextCodecUTF8::ConsumePartialSequenceBytes(int num_bytes) { … }
void TextCodecUTF8::HandleError(int character,
UChar*& destination,
bool stop_on_error,
bool& saw_error) { … }
template <>
bool TextCodecUTF8::HandlePartialSequence<LChar>(LChar*& destination,
const uint8_t*& source,
const uint8_t* end,
bool flush,
bool,
bool&) { … }
template <>
bool TextCodecUTF8::HandlePartialSequence<UChar>(UChar*& destination,
const uint8_t*& source,
const uint8_t* end,
bool flush,
bool stop_on_error,
bool& saw_error) { … }
namespace {
template <typename CharType>
class InlinedStringBuffer { … };
}
String TextCodecUTF8::Decode(const char* bytes,
wtf_size_t length,
FlushBehavior flush,
bool stop_on_error,
bool& saw_error) { … }
template <typename CharType>
std::string TextCodecUTF8::EncodeCommon(const CharType* characters,
wtf_size_t length) { … }
template <typename CharType>
TextCodec::EncodeIntoResult TextCodecUTF8::EncodeIntoCommon(
const CharType* characters,
wtf_size_t length,
unsigned char* destination,
size_t capacity) { … }
std::string TextCodecUTF8::Encode(const UChar* characters,
wtf_size_t length,
UnencodableHandling) { … }
std::string TextCodecUTF8::Encode(const LChar* characters,
wtf_size_t length,
UnencodableHandling) { … }
TextCodec::EncodeIntoResult TextCodecUTF8::EncodeInto(
const UChar* characters,
wtf_size_t length,
unsigned char* destination,
size_t capacity) { … }
TextCodec::EncodeIntoResult TextCodecUTF8::EncodeInto(
const LChar* characters,
wtf_size_t length,
unsigned char* destination,
size_t capacity) { … }
}