diff options
Diffstat (limited to 'src/utils/twtstr.nim')
-rw-r--r-- | src/utils/twtstr.nim | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/utils/twtstr.nim b/src/utils/twtstr.nim index 7589c262..64f66f88 100644 --- a/src/utils/twtstr.nim +++ b/src/utils/twtstr.nim @@ -546,6 +546,23 @@ func percentDecode*(input: string, si = 0): string = i += 2 inc i +func htmlEscape*(s: string): string = + var res = "" + for c in s: + if c == '<': + res &= "<" + elif c == '>': + res &= ">" + elif c == '&': + res &= "&" + elif c == '"': + res &= """ + elif c == '\'': + res &= "'" + else: + res &= c + return res + #basically std join but with char func join*(ss: openarray[string], sep: char): string = if ss.len == 0: |