pub fn detect_encoding(data: &[u8]) -> &'static strExpand description
Detect character encoding from byte data
Detection order:
- BOM (Byte Order Mark)
- XML declaration ()
- Default to UTF-8
§Arguments
data- Raw byte data
§Returns
Detected encoding name (e.g., “utf-8”, “iso-8859-1”)
§Examples
use feedparser_rs::util::encoding::detect_encoding;
// UTF-8 with BOM
let data = b"\xEF\xBB\xBF<?xml version=\"1.0\"?>";
assert_eq!(detect_encoding(data), "UTF-8");
// XML declaration
let data = b"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
assert_eq!(detect_encoding(data), "windows-1252");