readStringUtf8 method

String readStringUtf8()

Read a null-terminated UTF-8 string.

Implementation

String readStringUtf8() {
  final codes = <int>[];
  while (!isEOS) {
    final c = readByte();
    if (c == 0) {
      return utf8.decode(codes, allowMalformed: true);
    }
    codes.add(c);
  }
  throw ImageException('EOF reached without finding string terminator');
}