convert_utf16le_to_latin1

Function convert_utf16le_to_latin1 

Source
pub unsafe fn convert_utf16le_to_latin1(
    src: *const u16,
    len: usize,
    dst: *mut u8,
) -> usize
Expand description

Convert possibly broken UTF-16LE string into Latin1 string.

During the conversion also validation of the input string is done. This function is suitable to work with inputs from untrusted sources.

Returns the number of written code units; 0 if the input is not a valid UTF-16LE string

This function is not BOM-aware.

ยงSafety

  • src and dst must be non-null and properly aligned.
  • src must be valid for reads of len * size_of::<u16>() bytes
  • dst must be valid for writes of count * size_of::<u8>() bytes, where the count is the number of code units (u8) after successful conversion.
  • The memory regions of src and dst must not overlap.