Skip to main content

read_utf

Function read_utf 

Source
pub fn read_utf(
    data: &mut Cursor<&[u8]>,
    max_utf16_units: usize,
) -> Result<String>
Expand description

Reads a Minecraft UTF-8 string whose decoded length is bounded in Java UTF-16 code units.

Minecraft permits up to three encoded bytes per allowed UTF-16 code unit and replaces malformed UTF-8 with U+FFFD while decoding.

ยงErrors

Returns an error when the encoded byte length is negative, exceeds the maximum encoded length, is not fully available, or decodes to more than max_utf16_units UTF-16 code units.