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 */ |
| 27 @deprecated |
25 String codepointsToString(List<int> codepoints) { | 28 String codepointsToString(List<int> codepoints) { |
26 return new String.fromCharCodes(codepoints); | 29 return new String.fromCharCodes(codepoints); |
27 } | 30 } |
28 | 31 |
29 /** | 32 /** |
30 * Invalid codepoints or encodings may be substituted with the value U+fffd. | 33 * Invalid codepoints or encodings may be substituted with the value U+fffd. |
31 */ | 34 */ |
32 const int UNICODE_REPLACEMENT_CHARACTER_CODEPOINT = 0xfffd; | 35 const int UNICODE_REPLACEMENT_CHARACTER_CODEPOINT = 0xfffd; |
33 const int UNICODE_BOM = 0xfeff; | 36 const int UNICODE_BOM = 0xfeff; |
34 const int UNICODE_UTF_BOM_LO = 0xff; | 37 const int UNICODE_UTF_BOM_LO = 0xff; |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 _offset -= by; | 256 _offset -= by; |
254 } | 257 } |
255 | 258 |
256 int get remaining => _end - _offset - 1; | 259 int get remaining => _end - _offset - 1; |
257 | 260 |
258 void skip([int count = 1]) { | 261 void skip([int count = 1]) { |
259 _offset += count; | 262 _offset += count; |
260 } | 263 } |
261 } | 264 } |
262 | 265 |
OLD | NEW |