| 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 Converter<String, List<int>> |
| 73 implements ChunkedConverter<String, List<int>, String, List<int>> { |
| 74 |
| 73 final int _subsetMask; | 75 final int _subsetMask; |
| 74 | 76 |
| 75 const _UnicodeSubsetEncoder(this._subsetMask); | 77 const _UnicodeSubsetEncoder(this._subsetMask); |
| 76 | 78 |
| 77 /** | 79 /** |
| 78 * Converts the [String] into a list of its code units. | 80 * Converts the [String] into a list of its code units. |
| 79 * | 81 * |
| 80 * If [start] and [end] are provided, only the substring | 82 * If [start] and [end] are provided, only the substring |
| 81 * `string.substring(start, end)` is used as input to the conversion. | 83 * `string.substring(start, end)` is used as input to the conversion. |
| 82 */ | 84 */ |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 if (isLast) { | 149 if (isLast) { |
| 148 close(); | 150 close(); |
| 149 } | 151 } |
| 150 } | 152 } |
| 151 } | 153 } |
| 152 | 154 |
| 153 /** | 155 /** |
| 154 * This class converts Latin-1 bytes (lists of unsigned 8-bit integers) | 156 * This class converts Latin-1 bytes (lists of unsigned 8-bit integers) |
| 155 * to a string. | 157 * to a string. |
| 156 */ | 158 */ |
| 157 abstract class _UnicodeSubsetDecoder extends Converter<List<int>, String> { | 159 abstract class _UnicodeSubsetDecoder extends Converter<List<int>, String> |
| 160 implements ChunkedConverter<List<int>, String, List<int>, String> { |
| 161 |
| 158 final bool _allowInvalid; | 162 final bool _allowInvalid; |
| 159 final int _subsetMask; | 163 final int _subsetMask; |
| 160 | 164 |
| 161 /** | 165 /** |
| 162 * Instantiates a new decoder. | 166 * Instantiates a new decoder. |
| 163 * | 167 * |
| 164 * The [_allowInvalid] argument defines how [convert] deals | 168 * The [_allowInvalid] argument defines how [convert] deals |
| 165 * with invalid bytes. | 169 * with invalid bytes. |
| 166 * | 170 * |
| 167 * The [_subsetMask] argument is a bit mask used to define the subset | 171 * 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); | 305 RangeError.checkValidRange(start, end, length); |
| 302 if (start < end) { | 306 if (start < end) { |
| 303 if (start != 0 || end != length) { | 307 if (start != 0 || end != length) { |
| 304 source = source.sublist(start, end); | 308 source = source.sublist(start, end); |
| 305 } | 309 } |
| 306 add(source); | 310 add(source); |
| 307 } | 311 } |
| 308 if (isLast) close(); | 312 if (isLast) close(); |
| 309 } | 313 } |
| 310 } | 314 } |
| OLD | NEW |