readString method
read bytes_io formatted string
implementation details: lead by "length" bytes, encoded with 7-bit int the highest bit to indicate wheather there are more bytes to read.
the string is encoded in UTF8 codec
A reference to this implementation: https://referencesource.microsoft.com/#mscorlib/system/io/binaryreader.cs,f30b8b6e8ca06e0f
Implementation
String readString() {
int length = 0;
int shift = 0;
int b;
do {
b = readByte();
length |= (b & 0x7f) << shift;
shift += 7;
} while ((b & 0x80) != 0);
var data = readBytes(length);
return Utf8Decoder().convert(data);
}