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() {
utf32EncodedBytesIterator.moveNext();
int value = utf32EncodedBytesIterator.current;
utf32EncodedBytesIterator.moveNext();
value = (value << 8) + utf32EncodedBytesIterator.current;
utf32EncodedBytesIterator.moveNext();
value = (value << 8) + utf32EncodedBytesIterator.current;
utf32EncodedBytesIterator.moveNext();
value = (value << 8) + utf32EncodedBytesIterator.current;
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 current #
inherited from Utf32BytesDecoder
final int position #
inherited from Utf32BytesDecoder
int get position => utf32EncodedBytesIterator.position ~/ 4;
final int remaining #
inherited from Utf32BytesDecoder
int get remaining => (utf32EncodedBytesIterator.remaining + 3) ~/ 4;
final _ListRangeIterator utf32EncodedBytesIterator #
inherited from Utf32BytesDecoder
final _ListRangeIterator utf32EncodedBytesIterator
Methods
void backup([int by = 1]) #
inherited from Utf32BytesDecoder
void backup([int by = 1]) {
utf32EncodedBytesIterator.backup(4 * by);
}
int decode() #
int decode() {
utf32EncodedBytesIterator.moveNext();
int value = utf32EncodedBytesIterator.current;
utf32EncodedBytesIterator.moveNext();
value = (value << 8) + utf32EncodedBytesIterator.current;
utf32EncodedBytesIterator.moveNext();
value = (value << 8) + utf32EncodedBytesIterator.current;
utf32EncodedBytesIterator.moveNext();
value = (value << 8) + utf32EncodedBytesIterator.current;
return value;
}
List<int> decodeRest() #
inherited from Utf32BytesDecoder
List<int> decodeRest() {
List<int> codeunits = new List<int>(remaining);
int i = 0;
while (moveNext()) {
codeunits[i++] = current;
}
return codeunits;
}
bool moveNext() #
inherited from Utf32BytesDecoder
Moves to the next element. Returns true if current contains the next
element. Returns false, if no element was left.
It is safe to invoke moveNext even when the iterator is already
positioned after the last element. In this case moveNext has no effect.
bool moveNext() {
_current = null;
if (utf32EncodedBytesIterator.remaining < 4) {
utf32EncodedBytesIterator.skip(utf32EncodedBytesIterator.remaining);
if (replacementCodepoint != null) {
_current = replacementCodepoint;
return true;
} else {
throw new ArgumentError(
"Invalid UTF32 at ${utf32EncodedBytesIterator.position}");
}
} else {
int codepoint = decode();
if (_validCodepoint(codepoint)) {
_current = codepoint;
return true;
} else if (replacementCodepoint != null) {
_current = replacementCodepoint;
return true;
} else {
throw new ArgumentError(
"Invalid UTF32 at ${utf32EncodedBytesIterator.position}");
}
}
}
void skip([int count = 1]) #
inherited from Utf32BytesDecoder
void skip([int count = 1]) {
utf32EncodedBytesIterator.skip(4 * count);
}