| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 /** | 5 /** |
| 6 * Decodes the UTF-32 bytes as an iterable. Thus, the consumer can only convert | 6 * Decodes the UTF-32 bytes as an iterable. Thus, the consumer can only convert |
| 7 * as much of the input as needed. Determines the byte order from the BOM, | 7 * as much of the input as needed. Determines the byte order from the BOM, |
| 8 * or uses big-endian as a default. This method always strips a leading BOM. | 8 * or uses big-endian as a default. This method always strips a leading BOM. |
| 9 * Set the replacementCharacter to null to throw an ArgumentError | 9 * Set the replacementCharacter to null to throw an ArgumentError |
| 10 * rather than replace the bad value. | 10 * rather than replace the bad value. |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 utf32EncodedBytes[offset + 2] == 0 && utf32EncodedBytes[offset + 3] == 0; | 173 utf32EncodedBytes[offset + 2] == 0 && utf32EncodedBytes[offset + 3] == 0; |
| 174 } | 174 } |
| 175 | 175 |
| 176 typedef Utf32BytesDecoder Utf32BytesDecoderProvider(); | 176 typedef Utf32BytesDecoder Utf32BytesDecoderProvider(); |
| 177 | 177 |
| 178 /** | 178 /** |
| 179 * Return type of [decodeUtf32AsIterable] and variants. The Iterable type | 179 * Return type of [decodeUtf32AsIterable] and variants. The Iterable type |
| 180 * provides an iterator on demand and the iterator will only translate bytes | 180 * provides an iterator on demand and the iterator will only translate bytes |
| 181 * as requested by the user of the iterator. (Note: results are not cached.) | 181 * as requested by the user of the iterator. (Note: results are not cached.) |
| 182 */ | 182 */ |
| 183 class IterableUtf32Decoder implements Iterable<int> { | 183 class IterableUtf32Decoder extends Iterable<int> { |
| 184 final Utf32BytesDecoderProvider codeunitsProvider; | 184 final Utf32BytesDecoderProvider codeunitsProvider; |
| 185 | 185 |
| 186 IterableUtf32Decoder._(this.codeunitsProvider); | 186 IterableUtf32Decoder._(this.codeunitsProvider); |
| 187 | 187 |
| 188 Utf32BytesDecoder iterator() => codeunitsProvider(); | 188 Utf32BytesDecoder iterator() => codeunitsProvider(); |
| 189 } | 189 } |
| 190 | 190 |
| 191 /** | 191 /** |
| 192 * Abstrace parent class converts encoded bytes to codepoints. | 192 * Abstrace parent class converts encoded bytes to codepoints. |
| 193 */ | 193 */ |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 value += (utf32EncodedBytesIterator.next() << 24); | 310 value += (utf32EncodedBytesIterator.next() << 24); |
| 311 return value; | 311 return value; |
| 312 } | 312 } |
| 313 } | 313 } |
| 314 | 314 |
| 315 bool _validCodepoint(int codepoint) { | 315 bool _validCodepoint(int codepoint) { |
| 316 return (codepoint >= 0 && codepoint < UNICODE_UTF16_RESERVED_LO) || | 316 return (codepoint >= 0 && codepoint < UNICODE_UTF16_RESERVED_LO) || |
| 317 (codepoint > UNICODE_UTF16_RESERVED_HI && | 317 (codepoint > UNICODE_UTF16_RESERVED_HI && |
| 318 codepoint < UNICODE_VALID_RANGE_MAX); | 318 codepoint < UNICODE_VALID_RANGE_MAX); |
| 319 } | 319 } |
| OLD | NEW |