| 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 part of dart.utf; | 5 part of dart.utf; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Decodes the UTF-32 bytes as an iterable. Thus, the consumer can only convert | 8 * Decodes the UTF-32 bytes as an iterable. Thus, the consumer can only convert |
| 9 * as much of the input as needed. Determines the byte order from the BOM, | 9 * as much of the input as needed. Determines the byte order from the BOM, |
| 10 * or uses big-endian as a default. This method always strips a leading BOM. | 10 * or uses big-endian as a default. This method always strips a leading BOM. |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 final Utf32BytesDecoderProvider codeunitsProvider; | 188 final Utf32BytesDecoderProvider codeunitsProvider; |
| 189 | 189 |
| 190 IterableUtf32Decoder._(this.codeunitsProvider); | 190 IterableUtf32Decoder._(this.codeunitsProvider); |
| 191 | 191 |
| 192 Utf32BytesDecoder get iterator => codeunitsProvider(); | 192 Utf32BytesDecoder get iterator => codeunitsProvider(); |
| 193 } | 193 } |
| 194 | 194 |
| 195 /** | 195 /** |
| 196 * Abstrace parent class converts encoded bytes to codepoints. | 196 * Abstrace parent class converts encoded bytes to codepoints. |
| 197 */ | 197 */ |
| 198 class Utf32BytesDecoder implements _ListRangeIterator { | 198 abstract class Utf32BytesDecoder implements _ListRangeIterator { |
| 199 final _ListRangeIterator utf32EncodedBytesIterator; | 199 final _ListRangeIterator utf32EncodedBytesIterator; |
| 200 final int replacementCodepoint; | 200 final int replacementCodepoint; |
| 201 int _current = null; | 201 int _current = null; |
| 202 | 202 |
| 203 Utf32BytesDecoder._fromListRangeIterator( | 203 Utf32BytesDecoder._fromListRangeIterator( |
| 204 this.utf32EncodedBytesIterator, this.replacementCodepoint); | 204 this.utf32EncodedBytesIterator, this.replacementCodepoint); |
| 205 | 205 |
| 206 factory Utf32BytesDecoder(List<int> utf32EncodedBytes, [ | 206 factory Utf32BytesDecoder(List<int> utf32EncodedBytes, [ |
| 207 int offset = 0, int length, | 207 int offset = 0, int length, |
| 208 int replacementCodepoint = UNICODE_REPLACEMENT_CHARACTER_CODEPOINT]) { | 208 int replacementCodepoint = UNICODE_REPLACEMENT_CHARACTER_CODEPOINT]) { |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 value += (utf32EncodedBytesIterator.current << 24); | 329 value += (utf32EncodedBytesIterator.current << 24); |
| 330 return value; | 330 return value; |
| 331 } | 331 } |
| 332 } | 332 } |
| 333 | 333 |
| 334 bool _validCodepoint(int codepoint) { | 334 bool _validCodepoint(int codepoint) { |
| 335 return (codepoint >= 0 && codepoint < UNICODE_UTF16_RESERVED_LO) || | 335 return (codepoint >= 0 && codepoint < UNICODE_UTF16_RESERVED_LO) || |
| 336 (codepoint > UNICODE_UTF16_RESERVED_HI && | 336 (codepoint > UNICODE_UTF16_RESERVED_HI && |
| 337 codepoint < UNICODE_VALID_RANGE_MAX); | 337 codepoint < UNICODE_VALID_RANGE_MAX); |
| 338 } | 338 } |
| OLD | NEW |