Function uchardet::detect_encoding_name [] [src]

pub fn detect_encoding_name(data: &[u8]) -> Result<String>

Return the name of the charset used in data or an error if uchardet was unable to detect a charset.

use uchardet::detect_encoding_name;

assert_eq!("ASCII",
           detect_encoding_name("ascii".as_bytes()).unwrap());
assert_eq!("UTF-8",
           detect_encoding_name("©français".as_bytes()).unwrap());
assert_eq!("WINDOWS-1252",
           detect_encoding_name(&[0x46, 0x93, 0x72, 0x61, 0x6e, 0xe7, 0x6f,
               0x69, 0x73, 0xe9, 0x94]).unwrap());