Dart API Referencedart:utfUtf32leBytesDecoder

Utf32leBytesDecoder class

Convert UTF-32BE encoded bytes to codepoints by grouping 4 bytes to produce the unicode codepoint.

class Utf32leBytesDecoder extends Utf32BytesDecoder {
 Utf32leBytesDecoder(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 && hasUtf32leBom(utf32EncodedBytes, offset, length)) {
     skip();
   }
 }

 int decode() {
   utf32EncodedBytesIterator.moveNext();
   int value = utf32EncodedBytesIterator.current;
   utf32EncodedBytesIterator.moveNext();
   value += (utf32EncodedBytesIterator.current << 8);
   utf32EncodedBytesIterator.moveNext();
   value += (utf32EncodedBytesIterator.current << 16);
   utf32EncodedBytesIterator.moveNext();
   value += (utf32EncodedBytesIterator.current << 24);
   return value;
 }
}

Extends

Utf32BytesDecoder > Utf32leBytesDecoder

Constructors

new Utf32leBytesDecoder(List<int> utf32EncodedBytes, [int offset = 0, int length, bool stripBom = true, int replacementCodepoint = UNICODE_REPLACEMENT_CHARACTER_CODEPOINT]) #

Utf32leBytesDecoder(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 && hasUtf32leBom(utf32EncodedBytes, offset, length)) {
   skip();
 }
}

Properties

final int current #

inherited from Utf32BytesDecoder

Returns the current element.

Return null if the iterator has not yet been moved to the first element, or if the iterator has been moved after the last element of the Iterable.

docs inherited from Iterator<int>
int get current => _current;

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 int replacementCodepoint #

inherited from Utf32BytesDecoder
final int replacementCodepoint

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 += (utf32EncodedBytesIterator.current << 8);
 utf32EncodedBytesIterator.moveNext();
 value += (utf32EncodedBytesIterator.current << 16);
 utf32EncodedBytesIterator.moveNext();
 value += (utf32EncodedBytesIterator.current << 24);
 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.

docs inherited from Iterator<int>
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);
}