OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 |
| 5 part of dart.convert; |
| 6 |
| 7 /** |
| 8 * A [Utf8Encoder] converts strings to their UTF-8 code units (a list of |
| 9 * unsigned 8-bit integers). |
| 10 */ |
| 11 class Utf8Encoder extends Converter<String, List<int>> { |
| 12 /** |
| 13 * Converts [string] to its UTF-8 code units (a list of |
| 14 * unsigned 8-bit integers). |
| 15 */ |
| 16 List<int> convert(String string) => OLD_UTF_LIB.encodeUtf8(string); |
| 17 } |
| 18 |
| 19 /** |
| 20 * A [Utf8Decoder] converts UTF-8 code units (lists of unsigned 8-bit integers) |
| 21 * to a string. |
| 22 */ |
| 23 class Utf8Decoder extends Converter<List<int>, String> { |
| 24 /** |
| 25 * Converts the UTF-8 [codeUnits] (a list of unsigned 8-bit integers) to the |
| 26 * corresponding string. |
| 27 */ |
| 28 // TODO(floitsch): allow to configure the decoder (for example the replacement |
| 29 // character). |
| 30 String convert(List<int> codeUnits) => OLD_UTF_LIB.decodeUtf8(codeUnits); |
| 31 } |
OLD | NEW |