| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of dart.core; | 5 part of dart.core; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * A sequence of characters. | 8 * A sequence of characters. |
| 9 * | 9 * |
| 10 * A string can be either single or multiline. Single line strings are | 10 * A string can be either single or multiline. Single line strings are |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 external factory String.fromCharCodes(Iterable<int> charCodes); | 109 external factory String.fromCharCodes(Iterable<int> charCodes); |
| 110 | 110 |
| 111 /** | 111 /** |
| 112 * Allocates a new String for the specified [charCode]. | 112 * Allocates a new String for the specified [charCode]. |
| 113 * | 113 * |
| 114 * If the [charCode] can be represented by a single UTF-16 code unit, the new | 114 * If the [charCode] can be represented by a single UTF-16 code unit, the new |
| 115 * string contains a single code unit. Otherwise, the [length] is 2 and | 115 * string contains a single code unit. Otherwise, the [length] is 2 and |
| 116 * the code units form a surrogate pair. See documentation for | 116 * the code units form a surrogate pair. See documentation for |
| 117 * [fromCharCodes]. | 117 * [fromCharCodes]. |
| 118 * | 118 * |
| 119 * Creating a String with half of a surrogate pair is legal but generally | 119 * Creating a String with half of a surrogate pair is allowed. |
| 120 * discouraged. | |
| 121 */ | 120 */ |
| 122 factory String.fromCharCode(int charCode) { | 121 external factory String.fromCharCode(int charCode); |
| 123 List<int> charCodes = new List<int>.filled(1, charCode); | |
| 124 return new String.fromCharCodes(charCodes); | |
| 125 } | |
| 126 | 122 |
| 127 /** | 123 /** |
| 128 * Returns the string value of the environment declaration [name]. | 124 * Returns the string value of the environment declaration [name]. |
| 129 * | 125 * |
| 130 * Environment declarations are provided by the surrounding system compiling | 126 * Environment declarations are provided by the surrounding system compiling |
| 131 * or running the Dart program. Declarations map a string key to a string | 127 * or running the Dart program. Declarations map a string key to a string |
| 132 * value. | 128 * value. |
| 133 * | 129 * |
| 134 * If [name] is not declared in the environment, the result is instead | 130 * If [name] is not declared in the environment, the result is instead |
| 135 * [defaultValue]. | 131 * [defaultValue]. |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 _position = position - 1; | 727 _position = position - 1; |
| 732 _currentCodePoint = _combineSurrogatePair(prevCodeUnit, codeUnit); | 728 _currentCodePoint = _combineSurrogatePair(prevCodeUnit, codeUnit); |
| 733 return true; | 729 return true; |
| 734 } | 730 } |
| 735 } | 731 } |
| 736 _position = position; | 732 _position = position; |
| 737 _currentCodePoint = codeUnit; | 733 _currentCodePoint = codeUnit; |
| 738 return true; | 734 return true; |
| 739 } | 735 } |
| 740 } | 736 } |
| OLD | NEW |