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

Unified Diff: runtime/vm/json_stream.cc

Issue 2081433002: Use official JSON encoding for stream (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Removed STL from code Created 4 years, 6 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
« runtime/platform/text_buffer.cc ('K') | « runtime/platform/text_buffer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/json_stream.cc
diff --git a/runtime/vm/json_stream.cc b/runtime/vm/json_stream.cc
index f1a0d875d1e60ab9a0164ea12794ab2d3f1a9dd1..08f08edf6c2515cc9587de081fcf2a004109df6f 100644
--- a/runtime/vm/json_stream.cc
+++ b/runtime/vm/json_stream.cc
@@ -822,8 +822,14 @@ bool JSONStream::AddDartString(const String& s,
}
intptr_t limit = offset + count;
for (intptr_t i = offset; i < limit; i++) {
- intptr_t code_unit = s.CharAt(i);
- buffer_.EscapeAndAddCodeUnit(code_unit);
+ uint32_t code_unit = s.CharAt(i);
+ ASSERT(!Utf16::IsTrailSurrogate(code_unit));
+ if (Utf16::IsLeadSurrogate(code_unit)) {
+ uint32_t trail = s.CharAt(++i);
rmacnak 2016/06/21 16:56:56 A Dart string may have unmatched surrogates, so th
cbernaschina 2016/06/21 21:24:43 Done.
+ buffer_.EscapeAndAddCodeUnit(Utf16::Decode(code_unit, trail));
+ } else {
+ buffer_.EscapeAndAddCodeUnit(code_unit);
+ }
}
// Return value indicates whether the string is truncated.
return (offset > 0) || (limit < length);
« runtime/platform/text_buffer.cc ('K') | « runtime/platform/text_buffer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698