Utf32beBytesDecoder class
Convert UTF-32BE encoded bytes to codepoints by grouping 4 bytes to produce the unicode codepoint.
class Utf32beBytesDecoder extends Utf32BytesDecoder { Utf32beBytesDecoder(List<int> utf32EncodedBytes, [int offset = 0, int length, bool stripBom = true, int replacementCodepoint = UNICODE_REPLACEMENT_CHARACTER_CODEPOINT]) : super._fromListRangeIterator((new _ListRange(utf32EncodedBytes, offset, length)).iterator(), replacementCodepoint) { if (stripBom && hasUtf32beBom(utf32EncodedBytes, offset, length)) { skip(); } } int decode() { int value = utf32EncodedBytesIterator.next(); value = (value << 8) + utf32EncodedBytesIterator.next(); value = (value << 8) + utf32EncodedBytesIterator.next(); value = (value << 8) + utf32EncodedBytesIterator.next(); return value; } }
Extends
Utf32BytesDecoder > Utf32beBytesDecoder
Constructors
new Utf32beBytesDecoder(List<int> utf32EncodedBytes, [int offset = 0, int length, bool stripBom = true, int replacementCodepoint = UNICODE_REPLACEMENT_CHARACTER_CODEPOINT]) #
Utf32beBytesDecoder(List<int> utf32EncodedBytes, [int offset = 0, int length, bool stripBom = true, int replacementCodepoint = UNICODE_REPLACEMENT_CHARACTER_CODEPOINT]) : super._fromListRangeIterator((new _ListRange(utf32EncodedBytes, offset, length)).iterator(), replacementCodepoint) { if (stripBom && hasUtf32beBom(utf32EncodedBytes, offset, length)) { skip(); } }
Properties
final int position #
int get position => utf32EncodedBytesIterator.position ~/ 4;
final int remaining #
int get remaining => (utf32EncodedBytesIterator.remaining + 3) ~/ 4;
final _ListRangeIterator utf32EncodedBytesIterator #
final _ListRangeIterator utf32EncodedBytesIterator;
Methods
void backup([int by = 1]) #
void backup([int by = 1]) { utf32EncodedBytesIterator.backup(4 * by); }
int decode() #
int decode() { int value = utf32EncodedBytesIterator.next(); value = (value << 8) + utf32EncodedBytesIterator.next(); value = (value << 8) + utf32EncodedBytesIterator.next(); value = (value << 8) + utf32EncodedBytesIterator.next(); return value; }
List<int> decodeRest() #
List<int> decodeRest() { List<int> codeunits = new List<int>(remaining); int i = 0; while (hasNext()) { codeunits[i++] = next(); } return codeunits; }
bool hasNext() #
int next() #
Gets the next element in the iteration. Throws a
NoMoreElementsException
if no element is left.
int next() { if (utf32EncodedBytesIterator.remaining < 4) { utf32EncodedBytesIterator.skip(utf32EncodedBytesIterator.remaining); if (replacementCodepoint != null) { return replacementCodepoint; } else { throw new ArgumentError( "Invalid UTF32 at ${utf32EncodedBytesIterator.position}"); } } else { int codepoint = decode(); if (_validCodepoint(codepoint)) { return codepoint; } else if (replacementCodepoint != null) { return replacementCodepoint; } else { throw new ArgumentError( "Invalid UTF32 at ${utf32EncodedBytesIterator.position}"); } } }
void skip([int count = 1]) #
void skip([int count = 1]) { utf32EncodedBytesIterator.skip(4 * count); }