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 /** | 5 /** |
6 * Provide a list of Unicode codepoints for a given string. | 6 * Provide a list of Unicode codepoints for a given string. |
7 */ | 7 */ |
8 List<int> stringToCodepoints(String str) { | 8 List<int> stringToCodepoints(String str) { |
9 List<int> codepoints; | 9 List<int> codepoints; |
10 // TODO _is16BitCodeUnit() is used to work around a bug with dart2js | 10 // TODO _is16BitCodeUnit() is used to work around a bug with dart2js |
11 // (http://code.google.com/p/dart/issues/detail?id=1357). Consider | 11 // (http://code.google.com/p/dart/issues/detail?id=1357). Consider |
12 // removing after this issue is resolved. | 12 // removing after this issue is resolved. |
13 if (_is16BitCodeUnit()) { | 13 if (_is16BitCodeUnit()) { |
14 codepoints = _utf16CodeUnitsToCodepoints(str.charCodes()); | 14 codepoints = _utf16CodeUnitsToCodepoints(str.charCodes); |
15 } else { | 15 } else { |
16 codepoints = str.charCodes(); | 16 codepoints = str.charCodes; |
17 } | 17 } |
18 return codepoints; | 18 return codepoints; |
19 } | 19 } |
20 | 20 |
21 /** | 21 /** |
22 * Generate a string from the provided Unicode codepoints. | 22 * Generate a string from the provided Unicode codepoints. |
23 */ | 23 */ |
24 String codepointsToString(List<int> codepoints) { | 24 String codepointsToString(List<int> codepoints) { |
25 // TODO _is16BitCodeUnit() is used to work around a bug with dart2js | 25 // TODO _is16BitCodeUnit() is used to work around a bug with dart2js |
26 // (http://code.google.com/p/dart/issues/detail?id=1357). Consider | 26 // (http://code.google.com/p/dart/issues/detail?id=1357). Consider |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 _offset -= by; | 266 _offset -= by; |
267 } | 267 } |
268 | 268 |
269 int get remaining => _end - _offset; | 269 int get remaining => _end - _offset; |
270 | 270 |
271 void skip([int count = 1]) { | 271 void skip([int count = 1]) { |
272 _offset += count; | 272 _offset += count; |
273 } | 273 } |
274 } | 274 } |
275 | 275 |
OLD | NEW |