Index: sdk/lib/io/string_stream.dart |
diff --git a/sdk/lib/io/string_stream.dart b/sdk/lib/io/string_stream.dart |
index c16815327dba39d7f330498dd09b29db38ee91b9..00ff3bce2cd611e59820a265d49d22c4e314d0d5 100644 |
--- a/sdk/lib/io/string_stream.dart |
+++ b/sdk/lib/io/string_stream.dart |
@@ -270,6 +270,7 @@ class _UTF8Encoder implements _StringEncoder { |
static int _encodeString(String string, List<int> buffer) { |
int pos = 0; |
int length = string.length; |
+ // TODO(erikcorry): Use new iterator over charcodes. |
for (int i = 0; i < length; i++) { |
int additionalBytes; |
int charCode = string.charCodeAt(i); |
@@ -285,6 +286,7 @@ class _UTF8Encoder implements _StringEncoder { |
if (buffer != null) buffer[pos] = ((charCode >> 12) & 0x0F)| 0xE0; |
additionalBytes = 2; |
} else { |
+ i++; // Skip surrogate pair. |
// 11110xxx (xxx is top 3 bits) |
if (buffer != null) buffer[pos] = ((charCode >> 18) & 0x07) | 0xF0; |
additionalBytes = 3; |