readToArray
Reads a Modified UTF-8 string from the source and returns its characters as a CharArray in their original order.
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.
All indices in the returned array are populated by a character that was read from the source. There is no unused space at the beginning, end, or anywhere in the middle of the array.
Return
an array of all the characters that were read, in order. Note that its size...
will never exceed mutf8Length
will only be
0
if mutf8Length is also0
will never be
0
if mutf8Length is not0
either
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
.