| 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 IllegalArgumentException | 9 * Set the replacementCharacter to null to throw an IllegalArgumentException |
| 10 * rather than replace the bad value. | 10 * rather than replace the bad value. |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 return codepoint; | 241 return codepoint; |
| 242 } else if (replacementCodepoint != null) { | 242 } else if (replacementCodepoint != null) { |
| 243 return replacementCodepoint; | 243 return replacementCodepoint; |
| 244 } else { | 244 } else { |
| 245 throw new IllegalArgumentException( | 245 throw new IllegalArgumentException( |
| 246 "Invalid UTF32 at ${utf32EncodedBytesIterator.position}"); | 246 "Invalid UTF32 at ${utf32EncodedBytesIterator.position}"); |
| 247 } | 247 } |
| 248 } | 248 } |
| 249 } | 249 } |
| 250 | 250 |
| 251 int get position() => utf32EncodedBytesIterator.position ~/ 4; | 251 int get position => utf32EncodedBytesIterator.position ~/ 4; |
| 252 | 252 |
| 253 void backup([int by = 1]) { | 253 void backup([int by = 1]) { |
| 254 utf32EncodedBytesIterator.backup(4 * by); | 254 utf32EncodedBytesIterator.backup(4 * by); |
| 255 } | 255 } |
| 256 | 256 |
| 257 int get remaining() => (utf32EncodedBytesIterator.remaining + 3) ~/ 4; | 257 int get remaining => (utf32EncodedBytesIterator.remaining + 3) ~/ 4; |
| 258 | 258 |
| 259 void skip([int count = 1]) { | 259 void skip([int count = 1]) { |
| 260 utf32EncodedBytesIterator.skip(4 * count); | 260 utf32EncodedBytesIterator.skip(4 * count); |
| 261 } | 261 } |
| 262 | 262 |
| 263 abstract int decode(); | 263 abstract int decode(); |
| 264 } | 264 } |
| 265 | 265 |
| 266 /** | 266 /** |
| 267 * Convert UTF-32BE encoded bytes to codepoints by grouping 4 bytes | 267 * Convert UTF-32BE encoded bytes to codepoints by grouping 4 bytes |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 value += (utf32EncodedBytesIterator.next() << 24); | 309 value += (utf32EncodedBytesIterator.next() << 24); |
| 310 return value; | 310 return value; |
| 311 } | 311 } |
| 312 } | 312 } |
| 313 | 313 |
| 314 bool _validCodepoint(int codepoint) { | 314 bool _validCodepoint(int codepoint) { |
| 315 return (codepoint >= 0 && codepoint < UNICODE_UTF16_RESERVED_LO) || | 315 return (codepoint >= 0 && codepoint < UNICODE_UTF16_RESERVED_LO) || |
| 316 (codepoint > UNICODE_UTF16_RESERVED_HI && | 316 (codepoint > UNICODE_UTF16_RESERVED_HI && |
| 317 codepoint < UNICODE_VALID_RANGE_MAX); | 317 codepoint < UNICODE_VALID_RANGE_MAX); |
| 318 } | 318 } |
| OLD | NEW |