18 typedef unsigned char byte;
26 template <
class T,
int size = 256>
51 template <
class T,
int size = 256>
87 return (code & 0xfc00) == 0xd800;
91 return (code & 0xfc00) == 0xdc00;
95 return 0x10000 + ((lead & 0x3ff) << 10) + (trail & 0x3ff);
109 return 0xd800 + (((char_code - 0x10000) >> 10) & 0x3ff);
112 return 0xdc00 + (char_code & 0x3ff);
129 static inline unsigned Encode(
char* out,
132 bool replace_invalid =
false);
164 unsigned buffer_length,
165 const uint8_t* stream,
166 unsigned stream_length);
172 unsigned buffer_length,
173 const uint8_t* stream,
174 unsigned stream_length);
185 template <
unsigned kBufferSize>
189 inline Utf8Decoder(
const char* stream,
unsigned length);
190 inline void Reset(
const char* stream,
unsigned length);
227 bool* allow_caching_ptr);
235 bool* allow_caching_ptr);
242 bool* allow_caching_ptr);
249 bool* allow_caching_ptr);
256 bool* allow_caching_ptr);
static const unsigned kMaxChar
static uint16_t ConvertNonLatin1ToLatin1(uint16_t)
int CalculateValue(uchar c, uchar n, uchar *result)
CacheEntry entries_[kSize]
int get(uchar c, uchar n, uchar *result)
bool CalculateValue(uchar c)
CacheEntry entries_[kSize]
static const uchar kMaxCodePoint
static int GetByteCount()
static uint16_t LeadSurrogate(uint32_t char_code)
static const int kNoPreviousCharacter
static const uchar kMaxNonSurrogateCharCode
static const int kMaxExtraUtf8BytesForOneUtf16CodeUnit
static uint16_t TrailSurrogate(uint32_t char_code)
static bool IsSurrogatePair(int lead, int trail)
static int CombineSurrogatePair(uchar lead, uchar trail)
static bool IsTrailSurrogate(int code)
static const int kUtf8BytesToCodeASurrogate
static bool IsLeadSurrogate(int code)
unsigned Utf16Length() const
DISALLOW_COPY_AND_ASSIGN(Utf8DecoderBase)
bool last_byte_of_buffer_unused_
const uint8_t * unbuffered_start_
static void WriteUtf16Slow(const uint8_t *stream, uint16_t *data, unsigned length)
void Reset(uint16_t *buffer, unsigned buffer_length, const uint8_t *stream, unsigned stream_length)
void Reset(const char *stream, unsigned length)
unsigned WriteUtf16(uint16_t *data, unsigned length) const
uint16_t buffer_[kBufferSize]
static const unsigned kMaxThreeByteChar
static const unsigned kMaxOneByteChar
static uchar ValueOf(const byte *str, unsigned length, unsigned *cursor)
static const uchar kBadChar
static uchar Length(uchar chr, int previous)
static const unsigned kMaxFourByteChar
static const unsigned kMaxEncodedSize
static unsigned EncodeOneByte(char *out, uint8_t c)
static const unsigned kMaxTwoByteChar
static const unsigned kMax16BitCodeUnitSize
static unsigned Encode(char *out, uchar c, int previous, bool replace_invalid=false)
static const unsigned kBytesSavedByCombiningSurrogates
static const unsigned kSizeOfUnmatchedSurrogate
static uchar CalculateValue(const byte *str, unsigned length, unsigned *cursor)
enable harmony numeric enable harmony object literal extensions Optimize object size
const int kMaxMappingSize
The max length of the result of converting the case of a single character.
static const size_t kBufferSize
static const int kMaxWidth
static int Convert(uchar c, uchar n, uchar *result, bool *allow_caching_ptr)
static const int kMaxWidth
static int Convert(uchar c, uchar n, uchar *result, bool *allow_caching_ptr)
static int Convert(uchar c, uchar n, uchar *result, bool *allow_caching_ptr)
static const int kMaxWidth
CacheEntry(uchar code_point, signed offset)
CacheEntry(uchar code_point, bool value)
static const bool kIsToLower
static int Convert(uchar c, uchar n, uchar *result, bool *allow_caching_ptr)
static const int kMaxWidth
static const bool kIsToLower
static const int kMaxWidth
static int Convert(uchar c, uchar n, uchar *result, bool *allow_caching_ptr)