readLength

open override fun readLength(): Int(source)

Reads the length of a Modified UTF-8 string from the source of data.

This is done by reading the next 2 bytes from the underlying source of data and combining them in big-endian order into an unsigned 16-bit integer. That is, if byte1 and byte2 are the first and second bytes read respectively, and both are Bytes:

(byte1.toInt() and 0xFF shl 8) or (byte2.toInt() and 0xFF)

The returned value is an Int, though only the 16 least-significant bits represent the value; the rest of the bits are unset (0). Thus, the returned value will always be in the range 0 .. 65535.

Return

the mutf8Length value read from the source.

Throws

if there are fewer than 2 bytes left in the underlying source.

if the underlying source of bytes cannot be accessed.