detect_encoding

Function detect_encoding 

Source
pub fn detect_encoding(bytes: &[u8]) -> EncodingInfo
Expand description

Detect text encoding with confidence scoring

Analyzes byte content to determine the most likely encoding. Focuses on encodings commonly used in ASS subtitle files and provides confidence scoring based on content analysis.

§Arguments

  • bytes - Byte sequence to analyze

§Returns

EncodingInfo with detected encoding and confidence level

§Examples

let text = "[Script Info]\nTitle: Test";
let encoding = detect_encoding(text.as_bytes());
assert_eq!(encoding.encoding, "UTF-8");
assert!(encoding.confidence > 0.8);