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
#[warn(clippy::all, clippy::pedantic)]
#[allow(clippy::too_many_lines)]
pub mod lookup;
use std::collections::HashMap;
pub fn uniaxe(text: &str, table: &HashMap<char, char>) -> String {
let mut result = String::new();
for c in text.chars() {
if lookup::TEMPLATE.contains(c) {
result.push(c);
} else if let Some(&equiv) = table.get(&c) {
result.push(equiv);
} else if c.is_ascii() {
result.push(c);
}
}
result
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn conversion() {
let table = lookup::generate_table();
assert_eq!(
uniaxe("𝔥𝔢𝔩𝔩𝔬 𝔱𝔥𝔢𝔯𝔢 𝔈𝔫𝔍𝔬𝔶 𝔗𝔥𝔦𝔰 𝔊𝔬𝔗𝔥ℑ𝔠 𝕿𝖊𝖝𝖙 123", &table),
"hello there EnJoy This GoThIc Text 123"
);
assert_eq!(
uniaxe("𝓲𝓳𝓴𝓵𝓶fghijklm1234567890", &table),
"ijklmfghijklm1234567890"
);
assert_eq!(
uniaxe(
"●▬▬▬▬𝗟𝗮𝘀𝘁 𝗿𝗲𝗺𝗶𝗻𝗱𝗲𝗿,⛔️ 𝗬𝗼𝘂𝗿 𝗔𝗻𝘁𝗶𝘃𝗶𝗿𝘂𝘀 𝗲𝘅𝗽𝗶𝗿𝗲𝘀 𝗶𝗻 𝟮𝟰𝗵𝗿💯❗❗---▬▬▬▬▬● #UdL04",
&table
),
"Last reminder, Your Antivirus expires in 24hr--- #UdL04"
);
}
#[test]
fn normal() {
let table = lookup::generate_table();
assert_eq!(
uniaxe(
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
&table
),
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
);
}
}