| 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 [Latin1Codec]. | 8 * An instance of the default implementation of the [Latin1Codec]. |
| 9 * | 9 * |
| 10 * This instance provides a convenient access to the most common ISO Latin 1 | 10 * This instance provides a convenient access to the most common ISO Latin 1 |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 void addSlice(List<int> source, int start, int end, bool isLast) { | 242 void addSlice(List<int> source, int start, int end, bool isLast) { |
| 243 if (start < 0 || start > source.length) { | 243 if (start < 0 || start > source.length) { |
| 244 throw new RangeError.range(start, 0, source.length); | 244 throw new RangeError.range(start, 0, source.length); |
| 245 } | 245 } |
| 246 if (end < start || end > source.length) { | 246 if (end < start || end > source.length) { |
| 247 throw new RangeError.range(end, start, source.length); | 247 throw new RangeError.range(end, start, source.length); |
| 248 } | 248 } |
| 249 for (int i = start; i < end; i++) { | 249 for (int i = start; i < end; i++) { |
| 250 if ((source[i] & ~0xFF) != 0) { | 250 if ((source[i] & ~0xFF) != 0) { |
| 251 if (_allowInvalid) { | 251 if (_allowInvalid) { |
| 252 if (i > start) _addSliceToSink(source, start, i); | 252 if (i > start) _addSliceToSink(source, start, i, false); |
| 253 // Add UTF-8 encoding of U+FFFD. | 253 // Add UTF-8 encoding of U+FFFD. |
| 254 _addSliceToSink(const[0xFFFD], 0, 1, false); | 254 _addSliceToSink(const[0xFFFD], 0, 1, false); |
| 255 start = i + 1; | 255 start = i + 1; |
| 256 } else { | 256 } else { |
| 257 throw new FormatException("Source contains non-Latin-1 characters."); | 257 throw new FormatException("Source contains non-Latin-1 characters."); |
| 258 } | 258 } |
| 259 } | 259 } |
| 260 } | 260 } |
| 261 if (start < end) { | 261 if (start < end) { |
| 262 _addSliceToSink(source, start, end, isLast); | 262 _addSliceToSink(source, start, end, isLast); |
| 263 } else if (isLast) { | 263 } else if (isLast) { |
| 264 close(); | 264 close(); |
| 265 } | 265 } |
| 266 } | 266 } |
| 267 } | 267 } |
| OLD | NEW |