readUTF8 method

Future<String> readUTF8()

Reads a string encoded in UTF8. This method first reads a 2 byte unsigned integer decoded with the current endian setting, giving the number of UTF8 bytes to read. It then reads those bytes, and converts them to a string using Dart's UTF8 conversion. This may be incompatible with java.io.DataOutputStream for a string that contains nulls.

Throws EOFException if EOF is reached before the needed bytes are read.

Implementation

Future<String> readUTF8() async {
  final len = await readUnsignedShort();
  final bytes = await readBytesImmutable(len);
  return _utf8Decoder.convert(bytes);
}