1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#[macro_use]
mod macros;
pub fn x_to_accent(word: &str) -> String {
let word = word.chars().collect::<Vec<_>>();
let length = word.len();
let mut _new_word = String::from("");
let mut skip_x = false;
for i in 0..length {
if skip_x { skip_x = false; continue; }
let ch1 = word[i];
if accepts_hat!(ch1) {
if i < (length - 1) {
let ch2 = word[i + 1];
if is_x!(ch2) {
_new_word.push(accent_letter!(ch1));
skip_x = true;
}
else {
_new_word.push(ch1);
}
}
else {
_new_word.push(ch1);
}
}
else {
_new_word.push(ch1);
}
}
return _new_word;
}
pub fn remove_hyphens(word: &str) -> String {
return word.replace("-", "").replace("", "");
}
pub fn capitalize(s: &str) -> String {
let mut c = s.chars();
match c.next() {
None => String::new(),
Some(f) => f.to_uppercase().chain(c).collect(),
}
}
pub fn print_eo(s: &str) { print!("{}", x_to_accent(s)); }
pub fn println_eo(s: &str) { println!("{}", x_to_accent(s)); }
pub fn restore_capitals(original: &str, analyzed: &str) -> String {
let original_chars: Vec<_> = original.chars().collect();
let analyzed_chars = analyzed.chars();
let mut result = String::from("");
let mut index = 0;
for ch in analyzed_chars {
if ch == '.' {
result.push(ch);
}
else {
result.push(original_chars[index]);
index += 1;
}
}
return result;
}