pub fn validate_utf8(bytes: &[u8]) -> Result<(), CoreError>Expand description
Validate UTF-8 with detailed error information
Provides more detailed error reporting than standard UTF-8 validation, including the position and nature of encoding errors. Essential for processing subtitle files with encoding issues.
§Arguments
bytes- Byte sequence to validate
§Returns
Ok(()) if valid UTF-8, detailed error with position if invalid
§Examples
let valid_text = "Hello, 世界!";
assert!(validate_utf8(valid_text.as_bytes()).is_ok());
let invalid_bytes = &[0xFF, 0xFE, 0x80];
assert!(validate_utf8(invalid_bytes).is_err());§Errors
Returns an error if the byte slice contains invalid UTF-8 sequences.