6 #include "src/unicode-inl.h" 7 #include "src/unicode-decoder.h" 13 uint16_t Utf8Iterator::operator*() {
14 if (V8_UNLIKELY(char_ > Utf16::kMaxNonSurrogateCharCode)) {
15 return trailing_ ? Utf16::TrailSurrogate(char_)
16 : Utf16::LeadSurrogate(char_);
19 DCHECK_EQ(trailing_,
false);
23 Utf8Iterator& Utf8Iterator::operator++() {
24 if (V8_UNLIKELY(this->Done())) {
25 char_ = Utf8::kBufferEmpty;
29 if (V8_UNLIKELY(char_ > Utf16::kMaxNonSurrogateCharCode && !trailing_)) {
38 Utf8::ValueOf(reinterpret_cast<const uint8_t*>(stream_.begin()) + cursor_,
39 stream_.length() - cursor_, &cursor_);
43 Utf8Iterator Utf8Iterator::operator++(
int) {
44 Utf8Iterator old(*
this);
49 bool Utf8Iterator::Done() {
50 return offset_ ==
static_cast<size_t>(stream_.length());
53 void Utf8DecoderBase::Reset(uint16_t* buffer,
size_t buffer_length,
55 size_t utf16_length = 0;
57 Utf8Iterator it = Utf8Iterator(stream);
59 while (utf16_length < buffer_length && !it.Done()) {
64 bytes_read_ = it.Offset();
65 trailing_ = it.Trailing();
66 chars_written_ = utf16_length;
73 utf16_length_ = utf16_length;
76 void Utf8DecoderBase::WriteUtf16Slow(
77 uint16_t* data,
size_t length,
80 Utf8Iterator it = Utf8Iterator(stream, offset, trailing);
82 DCHECK_GT(length--, 0);