include!(concat!(env!("OUT_DIR"), "/translit_default_flat.rs"));
include!(concat!(env!("OUT_DIR"), "/translit_default_smp_phf.rs"));
include!(concat!(env!("OUT_DIR"), "/translit_langs_phf.rs"));
#[inline]
pub fn lookup(ch: char) -> Option<&'static str> {
let cp = ch as u32;
if (0x80..0x10000).contains(&cp) {
let base = DEFAULT_BMP_PAGES[(cp >> 8) as usize] as usize;
let cell = DEFAULT_BMP_ENTRIES[base + (cp & 0xFF) as usize];
if cell == u32::MAX {
None
} else {
let off = (cell >> 8) as usize;
let len = (cell & 0xFF) as usize;
Some(&DEFAULT_BMP_BLOB[off..off + len])
}
} else if cp >= 0x10000 {
DEFAULT_SMP.get(&ch).copied()
} else {
None
}
}
#[inline]
pub fn lookup_iso9(ch: char) -> Option<&'static str> {
ISO9.get(&ch).copied()
}
#[inline]
pub fn lookup_gost7034(ch: char) -> Option<&'static str> {
GOST7034.get(&ch).copied()
}
#[inline]
pub fn resolve_lang_map(lang: &str) -> Option<&'static phf::Map<char, &'static str>> {
let table: Option<&phf::Map<char, &'static str>> = match lang {
"de" => Some(&LANG_DE),
"no" | "nb" | "nn" | "da" => Some(&LANG_NO),
"sv" => Some(&LANG_SV),
"is" => Some(&LANG_IS),
"et" => Some(&LANG_ET),
"fr" => Some(&LANG_FR),
"es" => Some(&LANG_ES),
"pt" => Some(&LANG_PT),
"it" => Some(&LANG_IT),
"tr" => Some(&LANG_TR),
"nl" => Some(&LANG_NL),
"ca" => Some(&LANG_CA),
"vi" => Some(&LANG_VI),
"el" => Some(&LANG_EL),
"bg" => Some(&LANG_BG),
"uk" => Some(&LANG_UK),
"ru" => Some(&LANG_RU),
"sr" => Some(&LANG_SR),
"ja" => Some(&LANG_JA),
"ja-kunrei" => Some(&LANG_JA_KUNREI),
"fa" => Some(&LANG_FA), "am" => Some(&LANG_AM), _ => None,
};
table
}
#[inline]
pub fn lookup_lang(lang: &str, ch: char) -> Option<&'static str> {
resolve_lang_map(lang).and_then(|t| t.get(&ch).copied())
}