Skip to main content

validate_utf8

Function validate_utf8 

Source
pub fn validate_utf8(bytes: &[u8]) -> Result<&str, usize>
Expand description

Validates that a byte slice is valid UTF-8.

§Arguments

  • bytes - The bytes to validate.

§Returns

Ok(str) if valid, Err with the byte offset of the first invalid byte.

§Errors

Returns the byte offset of the first invalid UTF-8 sequence.