| 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 * An instance of the default implementation of the [AsciiCodec]. | 8 * An instance of the default implementation of the [AsciiCodec]. |
| 9 * | 9 * |
| 10 * This instance provides a convenient access to the most common ASCII | 10 * This instance provides a convenient access to the most common ASCII |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 | 62 |
| 63 AsciiEncoder get encoder => const AsciiEncoder(); | 63 AsciiEncoder get encoder => const AsciiEncoder(); |
| 64 | 64 |
| 65 AsciiDecoder get decoder => | 65 AsciiDecoder get decoder => |
| 66 _allowInvalid ? const AsciiDecoder(allowInvalid: true) | 66 _allowInvalid ? const AsciiDecoder(allowInvalid: true) |
| 67 : const AsciiDecoder(allowInvalid: false); | 67 : const AsciiDecoder(allowInvalid: false); |
| 68 } | 68 } |
| 69 | 69 |
| 70 // Superclass for [AsciiEncoder] and [Latin1Encoder]. | 70 // Superclass for [AsciiEncoder] and [Latin1Encoder]. |
| 71 // Generalizes common operations that only differ by a mask; | 71 // Generalizes common operations that only differ by a mask; |
| 72 class _UnicodeSubsetEncoder extends Converter<String, List<int>> { | 72 class _UnicodeSubsetEncoder extends |
| 73 ChunkedConverter<String, List<int>, String, List<int>> { |
| 73 final int _subsetMask; | 74 final int _subsetMask; |
| 74 | 75 |
| 75 const _UnicodeSubsetEncoder(this._subsetMask); | 76 const _UnicodeSubsetEncoder(this._subsetMask); |
| 76 | 77 |
| 77 /** | 78 /** |
| 78 * Converts the [String] into a list of its code units. | 79 * Converts the [String] into a list of its code units. |
| 79 * | 80 * |
| 80 * If [start] and [end] are provided, only the substring | 81 * If [start] and [end] are provided, only the substring |
| 81 * `string.substring(start, end)` is used as input to the conversion. | 82 * `string.substring(start, end)` is used as input to the conversion. |
| 82 */ | 83 */ |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 if (isLast) { | 148 if (isLast) { |
| 148 close(); | 149 close(); |
| 149 } | 150 } |
| 150 } | 151 } |
| 151 } | 152 } |
| 152 | 153 |
| 153 /** | 154 /** |
| 154 * This class converts Latin-1 bytes (lists of unsigned 8-bit integers) | 155 * This class converts Latin-1 bytes (lists of unsigned 8-bit integers) |
| 155 * to a string. | 156 * to a string. |
| 156 */ | 157 */ |
| 157 abstract class _UnicodeSubsetDecoder extends Converter<List<int>, String> { | 158 abstract class _UnicodeSubsetDecoder extends |
| 159 ChunkedConverter<List<int>, String, List<int>, String> { |
| 158 final bool _allowInvalid; | 160 final bool _allowInvalid; |
| 159 final int _subsetMask; | 161 final int _subsetMask; |
| 160 | 162 |
| 161 /** | 163 /** |
| 162 * Instantiates a new decoder. | 164 * Instantiates a new decoder. |
| 163 * | 165 * |
| 164 * The [_allowInvalid] argument defines how [convert] deals | 166 * The [_allowInvalid] argument defines how [convert] deals |
| 165 * with invalid bytes. | 167 * with invalid bytes. |
| 166 * | 168 * |
| 167 * The [_subsetMask] argument is a bit mask used to define the subset | 169 * The [_subsetMask] argument is a bit mask used to define the subset |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 RangeError.checkValidRange(start, end, length); | 303 RangeError.checkValidRange(start, end, length); |
| 302 if (start < end) { | 304 if (start < end) { |
| 303 if (start != 0 || end != length) { | 305 if (start != 0 || end != length) { |
| 304 source = source.sublist(start, end); | 306 source = source.sublist(start, end); |
| 305 } | 307 } |
| 306 add(source); | 308 add(source); |
| 307 } | 309 } |
| 308 if (isLast) close(); | 310 if (isLast) close(); |
| 309 } | 311 } |
| 310 } | 312 } |
| OLD | NEW |