| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 final int _subsetMask; | 73 final int _subsetMask; |
| 74 | 74 |
| 75 const _UnicodeSubsetEncoder(this._subsetMask); | 75 const _UnicodeSubsetEncoder(this._subsetMask); |
| 76 | 76 |
| 77 List<int> convert(String string) { | 77 List<int> convert(String string) { |
| 78 // TODO(11971): Use Uint8List when possible. | 78 List result = new Uint8List(string.length); |
| 79 List result = new List<int>(string.length); | |
| 80 for (int i = 0; i < string.length; i++) { | 79 for (int i = 0; i < string.length; i++) { |
| 81 var codeUnit = string.codeUnitAt(i); | 80 var codeUnit = string.codeUnitAt(i); |
| 82 if ((codeUnit & ~_subsetMask) != 0) { | 81 if ((codeUnit & ~_subsetMask) != 0) { |
| 83 throw new ArgumentError("String contains invalid characters."); | 82 throw new ArgumentError("String contains invalid characters."); |
| 84 } | 83 } |
| 85 result[i] = codeUnit; | 84 result[i] = codeUnit; |
| 86 } | 85 } |
| 87 return result; | 86 return result; |
| 88 } | 87 } |
| 89 | 88 |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 } | 299 } |
| 301 if (start < end) { | 300 if (start < end) { |
| 302 if (start != 0 || end != length) { | 301 if (start != 0 || end != length) { |
| 303 source = source.sublist(start, end); | 302 source = source.sublist(start, end); |
| 304 } | 303 } |
| 305 add(source); | 304 add(source); |
| 306 } | 305 } |
| 307 if (isLast) close(); | 306 if (isLast) close(); |
| 308 } | 307 } |
| 309 } | 308 } |
| OLD | NEW |