Skip to main content

detect_encoding

Function detect_encoding 

Source
pub fn detect_encoding<R: Read>(file: &mut R, unit: Unit) -> Result<String>
Expand description

The WHATWG name of the encoding of the text that file holds, from its start: UTF-16 as the unit says, else a UTF-8 BOM, else valid UTF-8 (a character cut at the end of the sample is not an error), else the detector’s guess, as the Editor’s own reader makes it. The probe says only “legacy” for a file that isn’t UTF-8.