Index: src/unicode.cc |
=================================================================== |
--- src/unicode.cc (revision 10944) |
+++ src/unicode.cc (working copy) |
@@ -276,6 +276,7 @@ |
return kBadChar; |
} |
+ |
const byte* Utf8::ReadBlock(Buffer<const char*> str, byte* buffer, |
unsigned capacity, unsigned* chars_read_ptr, unsigned* offset_ptr) { |
unsigned offset = *offset_ptr; |
@@ -338,6 +339,16 @@ |
return result; |
} |
+unsigned CharacterStream::Utf16Length() { |
+ unsigned result = 0; |
+ while (has_more()) { |
+ uchar c = GetNext(); |
+ result += c > Utf16::kMaxNonSurrogateCharCode ? 2 : 1; |
+ } |
+ Rewind(); |
+ return result; |
+} |
+ |
void CharacterStream::Seek(unsigned position) { |
Rewind(); |
for (unsigned i = 0; i < position; i++) { |