| 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 | 120 |
| 121 void add(List<int> source) { | 121 void add(List<int> source) { |
| 122 addSlice(source, 0, source.length, false); | 122 addSlice(source, 0, source.length, false); |
| 123 } | 123 } |
| 124 | 124 |
| 125 void _addSliceToSink(List<int> source, int start, int end, bool isLast) { | 125 void _addSliceToSink(List<int> source, int start, int end, bool isLast) { |
| 126 // If _sink was a UTF-16 conversion sink, just add the slice directly with | 126 // If _sink was a UTF-16 conversion sink, just add the slice directly with |
| 127 // _sink.addSlice(source, start, end, isLast). | 127 // _sink.addSlice(source, start, end, isLast). |
| 128 // The code below is an moderately stupid workaround until a real | 128 // The code below is an moderately stupid workaround until a real |
| 129 // solution can be made. | 129 // solution can be made. |
| 130 if (start == 0 && end == source.length) { | 130 _sink.add(new String.fromCharCodes(source, start, end)); |
| 131 _sink.add(new String.fromCharCodes(source)); | |
| 132 } else { | |
| 133 _sink.add(new String.fromCharCodes(source.sublist(start, end))); | |
| 134 } | |
| 135 if (isLast) close(); | 131 if (isLast) close(); |
| 136 } | 132 } |
| 137 | 133 |
| 138 void addSlice(List<int> source, int start, int end, bool isLast) { | 134 void addSlice(List<int> source, int start, int end, bool isLast) { |
| 139 if (start < 0 || start > source.length) { | 135 if (start < 0 || start > source.length) { |
| 140 throw new RangeError.range(start, 0, source.length); | 136 throw new RangeError.range(start, 0, source.length); |
| 141 } | 137 } |
| 142 if (end < start || end > source.length) { | 138 if (end < start || end > source.length) { |
| 143 throw new RangeError.range(end, start, source.length); | 139 throw new RangeError.range(end, start, source.length); |
| 144 } | 140 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 } | 173 } |
| 178 } | 174 } |
| 179 if (start < end) { | 175 if (start < end) { |
| 180 _addSliceToSink(source, start, end, isLast); | 176 _addSliceToSink(source, start, end, isLast); |
| 181 } | 177 } |
| 182 if (isLast) { | 178 if (isLast) { |
| 183 close(); | 179 close(); |
| 184 } | 180 } |
| 185 } | 181 } |
| 186 } | 182 } |
| OLD | NEW |