| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 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 | 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 part of dart.convert; | 5 part of dart.convert; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Open-ended Encoding enum. | 8 * Open-ended Encoding enum. |
| 9 */ | 9 */ |
| 10 abstract class Encoding extends Codec<String, List<int>> { | 10 abstract class Encoding extends Codec<String, List<int>> { |
| 11 const Encoding(); | 11 const Encoding(); |
| 12 | 12 |
| 13 ChunkedConverter<String, List<int>, String, List<int>> get encoder; |
| 14 ChunkedConverter<List<int>, String, List<int>, String> get decoder; |
| 15 |
| 13 Future<String> decodeStream(Stream<List<int>> byteStream) { | 16 Future<String> decodeStream(Stream<List<int>> byteStream) { |
| 14 return byteStream | 17 return byteStream |
| 15 .transform(decoder) | 18 .transform(decoder) |
| 16 .fold(new StringBuffer(), (buffer, string) => buffer..write(string)) | 19 .fold(new StringBuffer(), (buffer, string) => buffer..write(string)) |
| 17 .then((buffer) => buffer.toString()); | 20 .then((buffer) => buffer.toString()); |
| 18 } | 21 } |
| 19 | 22 |
| 20 /** | 23 /** |
| 21 * Name of the encoding. | 24 * Name of the encoding. |
| 22 * | 25 * |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 * The [name] passed is case insensitive. | 70 * The [name] passed is case insensitive. |
| 68 * | 71 * |
| 69 * If character set is not supported [:null:] is returned. | 72 * If character set is not supported [:null:] is returned. |
| 70 */ | 73 */ |
| 71 static Encoding getByName(String name) { | 74 static Encoding getByName(String name) { |
| 72 if (name == null) return null; | 75 if (name == null) return null; |
| 73 name = name.toLowerCase(); | 76 name = name.toLowerCase(); |
| 74 return _nameToEncoding[name]; | 77 return _nameToEncoding[name]; |
| 75 } | 78 } |
| 76 } | 79 } |
| OLD | NEW |