- Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhtml-entity-parser.rs
39 lines (34 loc) · 1.03 KB
/
html-entity-parser.rs
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
#![allow(dead_code, unused, unused_variables, non_snake_case)]
fnmain(){}
structSolution;
implSolution{
pubfnentity_parser(text:String) -> String{
letmut string = String::new();
letmut s = &text[..];
while !s.is_empty(){
if s.starts_with("""){
string.push('"');
s = &s[6..]
}elseif s.starts_with("&apos"){
string.push('\'');
s = &s[6..]
}elseif s.starts_with("&"){
string.push('&');
s = &s[5..]
}elseif s.starts_with(">"){
string.push('>');
s = &s[4..]
}elseif s.starts_with("<"){
string.push('<');
s = &s[4..]
}elseif s.starts_with("⁄"){
string.push('/');
s = &s[7..]
}else{
string.push_str(&s[0..1]);
s = &s[1..];
}
}
string
}
}