detect_and_convert

Function detect_and_convert 

Source
pub fn detect_and_convert(data: &[u8]) -> Result<(String, &'static str), String>
Expand description

Detect encoding and convert to UTF-8 in one step

§Examples

use feedparser_rs::util::encoding::detect_and_convert;

let data = b"<?xml version=\"1.0\"?><root>Test</root>";
let (utf8, detected_encoding) = detect_and_convert(data).unwrap();
assert_eq!(detected_encoding, "UTF-8");
assert!(utf8.contains("Test"));

§Errors

Returns an error if the encoding conversion encounters invalid byte sequences that cannot be properly decoded.