writeLength

open override fun writeLength(mutf8Length: Int)(source)

Writes the length of a Modified UTF-8 string to the sink's underlying destination.

This is done by taking the mutf8Length's 16 least-significant bits and splitting them into 2 bytes, which are then written in big-endian order. That is, if writeByte() is a method for writing an individual byte to the sink:

writeByte((mutf8Length shr 8).toByte())
writeByte(mutf8Length.toByte())

The mutf8Length parameter is an Int, though only the 16 least-significant bits represent the value. Every other bit should be unset or else an IllegalArgumentException will be thrown. Thus, mutf8Length must be in the range 0 .. 65535.

See also

Parameters

mutf8Length

The length of the string in question, in bytes.

Throws

if an I/O issue occurs while trying to write either of the bytes.