Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(207)

Unified Diff: sdk/lib/io/string_stream.dart

Issue 11368138: Add some support for the code-point code-unit distinction. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Implemented feedback from patch set 3 Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;

Powered by Google App Engine
This is Rietveld 408576698