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 library dart.utf; | 5 library dart.utf; |
6 import "dart:async"; | 6 import "dart:async"; |
7 part "utf_stream.dart"; | 7 part "utf_stream.dart"; |
8 part "utf8.dart"; | 8 part "utf8.dart"; |
9 part "utf16.dart"; | 9 part "utf16.dart"; |
10 part "utf32.dart"; | 10 part "utf32.dart"; |
11 | 11 |
12 // TODO(jmesserly): would be nice to have this on String (dartbug.com/6501). | 12 // TODO(jmesserly): would be nice to have this on String (dartbug.com/6501). |
13 /** | 13 /** |
14 * Provide a list of Unicode codepoints for a given string. | 14 * Provide a list of Unicode codepoints for a given string. |
15 */ | 15 */ |
16 List<int> stringToCodepoints(String str) { | 16 List<int> stringToCodepoints(String str) { |
17 // Note: str.codeUnits gives us 16-bit code units on all Dart implementations. | 17 // Note: str.codeUnits gives us 16-bit code units on all Dart implementations. |
18 // So we need to convert. | 18 // So we need to convert. |
19 return _utf16CodeUnitsToCodepoints(str.codeUnits); | 19 return _utf16CodeUnitsToCodepoints(str.codeUnits); |
20 } | 20 } |
21 | 21 |
22 /** | 22 /** |
23 * Generate a string from the provided Unicode codepoints. | 23 * Generate a string from the provided Unicode codepoints. |
| 24 * |
| 25 * *Deprecated* Use [String.fromCharCodes] instead. |
24 */ | 26 */ |
25 String codepointsToString(List<int> codepoints) { | 27 String codepointsToString(List<int> codepoints) { |
26 return new String.fromCharCodes(codepoints); | 28 return new String.fromCharCodes(codepoints); |
27 } | 29 } |
28 | 30 |
29 /** | 31 /** |
30 * Invalid codepoints or encodings may be substituted with the value U+fffd. | 32 * Invalid codepoints or encodings may be substituted with the value U+fffd. |
31 */ | 33 */ |
32 const int UNICODE_REPLACEMENT_CHARACTER_CODEPOINT = 0xfffd; | 34 const int UNICODE_REPLACEMENT_CHARACTER_CODEPOINT = 0xfffd; |
33 const int UNICODE_BOM = 0xfeff; | 35 const int UNICODE_BOM = 0xfeff; |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 _offset -= by; | 255 _offset -= by; |
254 } | 256 } |
255 | 257 |
256 int get remaining => _end - _offset - 1; | 258 int get remaining => _end - _offset - 1; |
257 | 259 |
258 void skip([int count = 1]) { | 260 void skip([int count = 1]) { |
259 _offset += count; | 261 _offset += count; |
260 } | 262 } |
261 } | 263 } |
262 | 264 |
OLD | NEW |