Dart API Referencedart:utfUtf32BytesDecoder

Utf32BytesDecoder Class

Abstrace parent class converts encoded bytes to codepoints.

Subclasses

Utf32beBytesDecoder, Utf32leBytesDecoder

Constructors

Code factory Utf32BytesDecoder(List<int> utf32EncodedBytes, [int offset = 0, int length, int replacementCodepoint = UNICODE_REPLACEMENT_CHARACTER_CODEPOINT]) #

factory Utf32BytesDecoder(List<int> utf32EncodedBytes, [
    int offset = 0, int length,
    int replacementCodepoint = UNICODE_REPLACEMENT_CHARACTER_CODEPOINT]) {
  if (length == null) {
    length = utf32EncodedBytes.length - offset;
  }
  if (hasUtf32beBom(utf32EncodedBytes, offset, length)) {
    return new Utf32beBytesDecoder(utf32EncodedBytes, offset + 4, length - 4,
        false, replacementCodepoint);
  } else if (hasUtf32leBom(utf32EncodedBytes, offset, length)) {
    return new Utf32leBytesDecoder(utf32EncodedBytes, offset + 4, length - 4,
        false, replacementCodepoint);
  } else {
    return new Utf32beBytesDecoder(utf32EncodedBytes, offset, length, false,
        replacementCodepoint);
  }
}

Code new Utf32BytesDecoder._fromListRangeIterator(_ListRangeIterator utf32EncodedBytesIterator, int replacementCodepoint) #

Utf32BytesDecoder._fromListRangeIterator(
    _ListRangeIterator this.utf32EncodedBytesIterator,
    int this.replacementCodepoint);

Methods

Code void backup([int by = 1]) #

void backup([int by = 1]) {
  utf32EncodedBytesIterator.backup(4 * by);
}

Code int decode() #

abstract int decode();

Code List<int> decodeRest() #

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

Code bool hasNext() #

bool hasNext() => utf32EncodedBytesIterator.hasNext();

Code int next() #

int next() {
  if (utf32EncodedBytesIterator.remaining < 4) {
    utf32EncodedBytesIterator.skip(utf32EncodedBytesIterator.remaining);
    if (replacementCodepoint != null) {
        return replacementCodepoint;
    } else {
      throw new IllegalArgumentException(
          "Invalid UTF32 at ${utf32EncodedBytesIterator.position}");
    }
  } else {
    int codepoint = decode();
    if (_validCodepoint(codepoint)) {
      return codepoint;
    } else if (replacementCodepoint != null) {
        return replacementCodepoint;
    } else {
      throw new IllegalArgumentException(
          "Invalid UTF32 at ${utf32EncodedBytesIterator.position}");
    }
  }
}

Code int get position() #

int get position() => utf32EncodedBytesIterator.position ~/ 4;

Code int get remaining() #

int get remaining() => (utf32EncodedBytesIterator.remaining + 3) ~/ 4;

Code void skip([int count = 1]) #

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

Fields

Code final int replacementCodepoint #

final int replacementCodepoint;

Code final _ListRangeIterator utf32EncodedBytesIterator #

final _ListRangeIterator utf32EncodedBytesIterator;