readUtf8Simple method

String readUtf8Simple(
  1. int length
)

Reads an UTF-8 string. Throws RawReaderException if a multi-byte rune is encountered.

Implementation

String readUtf8Simple(int length) {
  final bytes = _readUint8ListView(length);
  for (var i = 0; i < bytes.length; i++) {
    if (bytes[i] >= 128) {
      throw _newException(
        "Expected UTF-8 with single-byte runes, found a rune that's not single-byte",
        index: index - length + i,
      );
    }
  }
  return new String.fromCharCodes(bytes);
}