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() {
    int value = (utf32EncodedBytesIterator.next());
    value += (utf32EncodedBytesIterator.next() << 8);
    value += (utf32EncodedBytesIterator.next() << 16);
    value += (utf32EncodedBytesIterator.next() << 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 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() {
  int value = (utf32EncodedBytesIterator.next());
  value += (utf32EncodedBytesIterator.next() << 8);
  value += (utf32EncodedBytesIterator.next() << 16);
  value += (utf32EncodedBytesIterator.next() << 24);
  return value;
}

List<int> decodeRest() #

inherited from Utf32BytesDecoder
List<int> decodeRest() {
  List<int> codeunits = new List<int>(remaining);
  int i = 0;
  while (hasNext()) {
    codeunits[i++] = next();
  }
  return codeunits;
}

bool hasNext() #

inherited from Utf32BytesDecoder

Returns whether the Iterator has elements left.

docs inherited from Iterator<E>
bool hasNext() => utf32EncodedBytesIterator.hasNext();

int next() #

inherited from Utf32BytesDecoder

Gets the next element in the iteration. Throws a NoMoreElementsException if no element is left.

docs inherited from Iterator<E>
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]) #

inherited from Utf32BytesDecoder
void skip([int count = 1]) {
  utf32EncodedBytesIterator.skip(4 * count);
}