Skip to content

Instantly share code, notes, and snippets.

@inky
Last active September 6, 2015 09:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save inky/fb0b961be7f5cd8abbd4 to your computer and use it in GitHub Desktop.
Save inky/fb0b961be7f5cd8abbd4 to your computer and use it in GitHub Desktop.
Ogham transliterator in Rust
fn transliterate(ogham: &str) -> String {
ogham.chars().filter_map(|token| match token {
' ' => Some(" "),
'ᚁ' => Some("B"),
'ᚂ' => Some("L"),
'ᚃ' => Some("F"),
'ᚄ' => Some("S"),
'ᚅ' => Some("N"),
'ᚆ' => Some("H"),
'ᚇ' => Some("D"),
'ᚈ' => Some("T"),
'ᚉ' => Some("C"),
'ᚊ' => Some("Q"),
'ᚋ' => Some("M"),
'ᚌ' => Some("G"),
'ᚍ' => Some("NG"),
'ᚎ' => Some("Z"),
'ᚏ' => Some("R"),
'ᚐ' => Some("A"),
'ᚑ' => Some("O"),
'ᚒ' => Some("U"),
'ᚓ' => Some("E"),
'ᚔ' => Some("I"),
'ᚕ' => Some("EA"),
'ᚖ' => Some("OI"),
'ᚗ' => Some("UI"),
'ᚘ' => Some("IA"),
'ᚙ' => Some("AE"),
'ᚚ' => Some("P"),
_ => None,
}).fold(String::new(), |s, frag| s + frag)
}
fn main() {
println!("{}", transliterate("᚛ᚊᚏᚔᚋᚔᚈᚔᚏ ᚏᚑᚅᚐᚅᚅ ᚋᚐᚊ ᚉᚑᚋᚑᚌᚐᚅᚅ᚜"));
}
$ rustc ogham.rs
$ ./ogham
QRIMITIR RONANN MAQ COMOGANN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment