Skip to main content

read_utf16_string

Function read_utf16_string 

Source
pub fn read_utf16_string(
    src: &mut impl Buf,
    char_count: usize,
) -> Option<String>
Expand description

Read a UTF-16LE string of specified character length.

Malformed UCS-2 (e.g. an unpaired surrogate) is decoded lossily, with each invalid unit replaced by U+FFFD, rather than failing. This keeps None meaning unambiguously “not enough bytes in the buffer” so callers do not conflate a decode failure with end-of-input.