mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
21 lines
648 B
V
21 lines
648 B
V
|
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 {
|
||
|
mut escape_to_text := ['&', '&', '<', '<', '>', '>', ''', "'", '"', '"', '&', '&', '<', '<', '>', '>', ''', "'", '"', '"', '&', '&', '<', '<', '>', '>', ''', "'", '"', '"']
|
||
|
return input.replace_each(escape_to_text)
|
||
|
}
|