| 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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 void backup([int by = 1]) { | 254 void backup([int by = 1]) { |
| 255 utf32EncodedBytesIterator.backup(4 * by); | 255 utf32EncodedBytesIterator.backup(4 * by); |
| 256 } | 256 } |
| 257 | 257 |
| 258 int get remaining => (utf32EncodedBytesIterator.remaining + 3) ~/ 4; | 258 int get remaining => (utf32EncodedBytesIterator.remaining + 3) ~/ 4; |
| 259 | 259 |
| 260 void skip([int count = 1]) { | 260 void skip([int count = 1]) { |
| 261 utf32EncodedBytesIterator.skip(4 * count); | 261 utf32EncodedBytesIterator.skip(4 * count); |
| 262 } | 262 } |
| 263 | 263 |
| 264 abstract int decode(); | 264 int decode(); |
| 265 } | 265 } |
| 266 | 266 |
| 267 /** | 267 /** |
| 268 * Convert UTF-32BE encoded bytes to codepoints by grouping 4 bytes | 268 * Convert UTF-32BE encoded bytes to codepoints by grouping 4 bytes |
| 269 * to produce the unicode codepoint. | 269 * to produce the unicode codepoint. |
| 270 */ | 270 */ |
| 271 class Utf32beBytesDecoder extends Utf32BytesDecoder { | 271 class Utf32beBytesDecoder extends Utf32BytesDecoder { |
| 272 Utf32beBytesDecoder(List<int> utf32EncodedBytes, [int offset = 0, | 272 Utf32beBytesDecoder(List<int> utf32EncodedBytes, [int offset = 0, |
| 273 int length, bool stripBom = true, | 273 int length, bool stripBom = true, |
| 274 int replacementCodepoint = UNICODE_REPLACEMENT_CHARACTER_CODEPOINT]) : | 274 int replacementCodepoint = UNICODE_REPLACEMENT_CHARACTER_CODEPOINT]) : |
| (...skipping 35 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 |