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

Unified Diff: sdk/lib/_internal/compiler/implementation/scanner/token.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: New version integrates feedback, adds less to standard String class. 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/_internal/compiler/implementation/scanner/token.dart
diff --git a/sdk/lib/_internal/compiler/implementation/scanner/token.dart b/sdk/lib/_internal/compiler/implementation/scanner/token.dart
index 901202139bcdf4c3205b7c3b2e56229eef259021..9f726ec8dd49e98ca77100fc04e1e287bd2fc0cc 100644
--- a/sdk/lib/_internal/compiler/implementation/scanner/token.dart
+++ b/sdk/lib/_internal/compiler/implementation/scanner/token.dart
@@ -231,6 +231,9 @@ class StringWrapper implements SourceString {
bool isPrivate() => !isEmpty && identical(stringValue.charCodeAt(0), $_);
}
+
+// TODO(erikcorry): Use the new code point iterator on String when it is
+// available.
class StringCodeIterator implements Iterator<int> {
final String string;
int index;
@@ -246,7 +249,12 @@ class StringCodeIterator implements Iterator<int> {
}
bool get hasNext => index < end;
- int next() => string.charCodeAt(index++);
+ int next() {
+ int charCode = string.charCodeAt(index++);
+ // Skip trail surrogate.
+ if (charCode >= String.SMP_CODE_POINT_BASE) index++;
+ return charCode;
+ }
}
class BeginGroupToken extends StringToken {

Powered by Google App Engine
This is Rietveld 408576698