readToAppendable
Reads a Modified UTF-8 string from the source and appends each of its characters, in order, to an Appendable, such as a StringBuilder.
This method does not read the 2-byte "UTF length" that comes before standard Modified UTF-8 strings. That must be read separately (if applicable) and passed to this method via the mutf8Length parameter.
Parameters
The number of bytes used to encode the string. This must be at least 0
and at most 65535
(UShort.MAX_VALUE).
Unless an EOFException or IOException is thrown, this is exactly the number of bytes that are read by this method.
Throws
if mutf8Length exceeds UShort.MAX_VALUE.
if readBytes returns fewer bytes than expected by the mutf8Length.
if readBytes returns more bytes than expected by the mutf8Length.
if the second and/or third byte of a character does not have its most-significant bit set (1
) and its second-most-significant bit unset (0
), which is required for the second and third bytes of 2-byte and 3-byte characters. In other words, either byte's bits don't follow the pattern 10xx xxxx
, where each x
can be either a 1
or 0
.