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

Unified Diff: runtime/vm/scanner.cc

Issue 23000008: Fixes scanning of Utf16 surrogate pairs in string literals. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 4 months 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
« no previous file with comments | « runtime/vm/flow_graph_builder.cc ('k') | tests/language/unicode_hash_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/scanner.cc
===================================================================
--- runtime/vm/scanner.cc (revision 26056)
+++ runtime/vm/scanner.cc (working copy)
@@ -581,7 +581,20 @@
string_chars.Add(string_delimiter_);
}
} else {
- string_chars.Add(c0_);
+ // Test for a two part utf16 sequence, and decode to a code point
+ // if we find one.
+ int32_t ch1 = c0_;
+ if (Utf16::IsLeadSurrogate(ch1)) {
+ ReadChar();
+ const int32_t ch2 = c0_;
+ if (Utf16::IsTrailSurrogate(ch2)) {
+ ch1 = Utf16::Decode(ch1, ch2);
+ } else {
+ string_chars.Add(ch1);
+ continue;
Ivan Posva 2013/08/14 05:21:52 Can you restructure this to avoid the continue?
zra 2013/08/14 14:59:11 Yes. Missed the LookaheadChar function before.
+ }
+ }
+ string_chars.Add(ch1);
}
ReadChar();
}
« no previous file with comments | « runtime/vm/flow_graph_builder.cc ('k') | tests/language/unicode_hash_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698