1use gobble::*;
2pub mod dict;
3pub mod parser;
4
5fn cons_str(n: u32) -> &'static str {
6 match n {
7 0 => "k",
8 1 => "d",
9 2 => "ch",
10 3 => "s",
11 4 => "y",
12 5 => "h",
13 6 => "f",
14 7 => "w",
15 8 => "m",
16 9 => "j",
17 10 => "b",
18 11 => "n",
19 12 => "th",
20 13 => "fl",
21 _ => "#",
22 }
23}
24
25pub fn romanize_char(c: char) -> String {
26 if !parser::MiChar.char_bool(c) {
27 return c.to_string();
28 }
29 let n = c as u32 - 0xe000;
30 let cons = n % 14;
31 let vow = n / 14;
32 let mut res = cons_str(cons).to_string();
33 res.push_str(match vow {
34 0 => "",
35 1 => "a",
36 2 => "i",
37 3 => "o",
38 4 => "u",
39 _ => "#",
40 });
41 res
42}
43
44pub fn romanize_str(s: &str) -> String {
45 let mut res = String::new();
46 for c in s.chars() {
47 if parser::MiChar.char_bool(c) {
48 res.push_str(&romanize_char(c))
49 } else {
50 res.push(c)
51 }
52 }
53 res
54}