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 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 if ((source[i] & ~_ASCII_MASK) != 0) { | 285 if ((source[i] & ~_ASCII_MASK) != 0) { |
286 throw new FormatException("Source contains non-ASCII bytes."); | 286 throw new FormatException("Source contains non-ASCII bytes."); |
287 } | 287 } |
288 } | 288 } |
289 _sink.add(new String.fromCharCodes(source)); | 289 _sink.add(new String.fromCharCodes(source)); |
290 } | 290 } |
291 | 291 |
292 void addSlice(List<int> source, int start, int end, bool isLast) { | 292 void addSlice(List<int> source, int start, int end, bool isLast) { |
293 final int length = source.length; | 293 final int length = source.length; |
294 if (start < 0 || start > length) { | 294 if (start < 0 || start > length) { |
295 throw new RangeError.range(start, 0, length - 1); | 295 throw new RangeError.range(start, 0, length); |
296 } | 296 } |
297 if (end < start || end > length) { | 297 if (end < start || end > length) { |
298 throw new RangeError.range(end, start, length - 1); | 298 throw new RangeError.range(end, start, length); |
299 } | 299 } |
300 if (start < end) { | 300 if (start < end) { |
301 if (start != 0 || end != length) { | 301 if (start != 0 || end != length) { |
302 source = source.sublist(start, end); | 302 source = source.sublist(start, end); |
303 } | 303 } |
304 add(source); | 304 add(source); |
305 } | 305 } |
306 if (isLast) close(); | 306 if (isLast) close(); |
307 } | 307 } |
308 } | 308 } |
OLD | NEW |