[−][src]Function encoding_rs::mem::convert_utf16_to_utf8
pub fn convert_utf16_to_utf8(src: &[u16], dst: &mut [u8]) -> usize
Converts potentially-invalid UTF-16 to valid UTF-8 with errors replaced with the REPLACEMENT CHARACTER.
The length of the destination buffer must be at least the length of the source buffer times three plus one.
Returns the number of bytes written.
Panics
Panics if the destination buffer is shorter than stated above.
Safety
Note that this function may write garbage beyond the number of bytes
indicated by the return value, so using a &mut str
interpreted as
&mut [u8]
as the destination is not safe. If you want to convert into
a &mut str
, use convert_utf16_to_str()
instead of this function.