1 include!(concat!(env!("OUT_DIR"), "/encodings.rs"));
3 pub fn codepage_from_encoding(encoding: &str) -> Option<u32> {
4 CODEPAGE_NAME_TO_NUMBER
5 .get(encoding.to_ascii_lowercase().as_str())
9 pub fn encoding_from_hints(encoding: Option<&str>, codepage: Option<u32>) -> Option<&str> {
10 if encoding.is_some() {
12 } else if let Some(codepage) = codepage {
14 1 => Some("EBCDIC-US"),
16 // These ostensibly mean "7-bit ASCII" and "8-bit ASCII"[sic]
17 // respectively. However, many files have character code 2 but
18 // data which are clearly not ASCII. Therefore, ignore these
22 4 => Some("MS_KANJI"),
23 _ => CODEPAGE_NUMBER_TO_NAME.get(&codepage).copied()