Last active
September 6, 2015 09:15
-
-
Save inky/fb0b961be7f5cd8abbd4 to your computer and use it in GitHub Desktop.
Ogham transliterator in Rust
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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("᚛ᚊᚏᚔᚋᚔᚈᚔᚏ ᚏᚑᚅᚐᚅᚅ ᚋᚐᚊ ᚉᚑᚋᚑᚌᚐᚅᚅ᚜")); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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