encoding_utf8_valid_up_to

Function encoding_utf8_valid_up_to 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn encoding_utf8_valid_up_to( buffer: *const u8, buffer_len: usize, ) -> usize
Expand description

Validates UTF-8.

Returns the index of the first byte that makes the input malformed as UTF-8 or buffer_len if buffer is entirely valid.

buffer must be non-NULL even if buffer_len is zero. When buffer_len is zero, it is OK for buffer to be something non-dereferencable, such as 0x1. This is required due to Rust’s optimization for slices within Option.

§Undefined behavior

UB ensues if buffer and buffer_len don’t designate a valid memory block of if buffer is NULL.