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

Unified Diff: sdk/lib/_internal/compiler/implementation/lib/js_helper.dart

Issue 11418115: Fix Unicode issues in dart2js and dart2dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove accidental test expectation dupe 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/lib/js_helper.dart
diff --git a/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart b/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart
index 279ee270849d8dd3f34dc94de87ee8f05a6af0d6..fc998c387aebbb35f13f7f7be8eef977f05ff8c2 100644
--- a/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart
+++ b/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart
@@ -535,9 +535,27 @@ class Primitives {
static num dateNow() => JS('num', r'Date.now()');
+ static stringFromCodePoints(codePoints) {
+ List<int> a = <int>[];
+ for (var i in codePoints) {
+ if (i is !int) throw new ArgumentError(i);
+ if (i <= 0xffff) {
+ JS('void', r'#.push(#)', a, i);
+ } else if (i <= 0x10ffff) {
+ JS('void', r'#.push(0xd800 + ((((#) >> 10) & 0x3ff)))', a, i - 0x10000);
+ JS('void', r'#.push(#)', a, 0xdc00 + (i & 0x3ff));
+ } else {
+ throw new ArgumentError(i);
+ }
+ }
+ return JS('String', r'String.fromCharCode.apply(#, #)', null, a);
+ }
+
static String stringFromCharCodes(charCodes) {
for (var i in charCodes) {
if (i is !int) throw new ArgumentError(i);
+ if (i < 0) throw new ArgumentError(i);
+ if (i > 0xffff) return stringFromCodePoints(charCodes);
}
return JS('String', r'String.fromCharCode.apply(#, #)', null, charCodes);
}

Powered by Google App Engine
This is Rietveld 408576698