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.codec; |
| 6 |
| 7 /** |
| 8 * Open-ended Encoding enum. |
| 9 */ |
| 10 // TODO(floitsch): dart:io already has an Encoding class. If we can't |
| 11 // consolitate them, we need to remove `Encoding` here. |
| 12 abstract class Encoding extends Codec<String, List<int>> { |
| 13 const Encoding(); |
| 14 } |
| 15 |
| 16 // TODO(floitsch): add other encodings, like ASCII and ISO_8859_1. |
| 17 const UTF8 = const Utf8Codec(); |
| 18 |
| 19 /** |
| 20 * A [Utf8Codec] encodes strings to utf-8 code units (bytes) and decodes |
| 21 * UTF-8 code units to strings. |
| 22 */ |
| 23 // TODO(floitsch): Needs a way to specify if decoding should throw or use |
| 24 // the replacement character. |
| 25 class Utf8Codec extends Encoding { |
| 26 const Utf8Codec(); |
| 27 |
| 28 Converter<String, List<int>> get encoder => new Utf8Encoder(); |
| 29 Converter<List<int>, String> get decoder => new Utf8Decoder(); |
| 30 } |
OLD | NEW |