Skip to main content

convert_utf16be_to_utf8

Function convert_utf16be_to_utf8 

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

Convert possibly broken UTF-16BE string into UTF-8 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-16BE 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.