2023-07-20 22:25:24 +03:00
|
|
|
module html
|
|
|
|
|
|
|
|
/*
|
|
|
|
unescape() automatically convert HTML Encoded text to its original text
|
|
|
|
and it doesn't matter the HTML Encoded be in which type (symbolic, decimal, hex)
|
|
|
|
all the types are supported
|
|
|
|
Usage:
|
|
|
|
```
|
|
|
|
import html
|
|
|
|
fn main() {
|
|
|
|
text := "Hello, 'World'"
|
|
|
|
decode := html.unescape(text)
|
|
|
|
println(decode)
|
|
|
|
}
|
|
|
|
```
|
|
|
|
*/
|
|
|
|
pub fn unescape(input string) string {
|
2023-07-21 08:15:57 +03:00
|
|
|
mut escape_to_text := ['&', '&', '<', '<', '>', '>', ''', "'", '"', '"',
|
|
|
|
'&', '&', '<', '<', '>', '>', ''', "'", '"', '"', '&', '&', '<',
|
|
|
|
'<', '>', '>', ''', "'", '"', '"']
|
2023-07-20 22:25:24 +03:00
|
|
|
return input.replace_each(escape_to_text)
|
|
|
|
}
|