Function ensure_utf16_validity

fn ensure_utf16_validity(buffer: &mut [u16])

Replaces unpaired surrogates in the input with the REPLACEMENT CHARACTER.