Chromium Code Reviews| Index: runtime/lib/string_patch.dart |
| diff --git a/runtime/lib/string_patch.dart b/runtime/lib/string_patch.dart |
| index 717e49db71984f56878bbfcf0cde617c7efb3be5..299ad6a8bda0a86cab119252297427f6caaf3a2c 100644 |
| --- a/runtime/lib/string_patch.dart |
| +++ b/runtime/lib/string_patch.dart |
| @@ -7,6 +7,24 @@ patch class String { |
| return _StringBase.createFromCharCodes(charCodes); |
| } |
| + /* patch */ factory String.fromCharCode(int charCode) { |
| + if (charCode >= 0) { |
| + if (charCode <= 0xff) { |
| + return _OneByteString._allocate(1).._setAt(0, charCode); |
| + } |
| + if (charCode <= 0xffff) { |
|
Lasse Reichstein Nielsen
2014/03/26 09:59:59
What should I do to get _TwoByteString._allocate t
Søren Gjesse
2014/03/26 10:10:33
I think you can just add to to string.cc and send
|
| + return _StringBase._createFromCodePoints([charCode]); |
| + } |
| + if (charCode <= 0x10ffff) { |
| + var low = 0xDC00 | (charCode & 0x3ff); |
| + int bits = charCode - 0x10000; |
| + var high = 0xD800 | (bits >> 10); |
| + return _StringBase._createFromCodePoints([high, low]); |
| + } |
| + } |
| + throw new RangeError.range(charCode, 0, 0x10ffff); |
| + } |
| + |
| /* patch */ const factory String.fromEnvironment(String name, |
| {String defaultValue}) |
| native "String_fromEnvironment"; |