HTMLDecode + HTMLEncode

Decode and encode back a string using HTML
Technically found online, but enhanced and added some more characters.
It is decodes/encodes only up to char ascii of 255, we might remove that or increase it to include other languages.

CodeFunctionName
What is this?

Public

Tested

Original Work
<%
' HTMLDecode + HTMLEncode functions
' The HTMLDecode function decodes an HTML encoded string back into the original html code.
Function HTMLDecode(String1)
tmp = String1
tmp = Replace( tmp, """, chr(34) )
tmp = Replace( tmp, "<", chr(60) )
tmp = Replace( tmp, ">", chr(62) )
tmp = Replace( tmp, "&", chr(38) )
tmp = Replace( tmp, " ", chr(32) )
For i = 1 to 255
tmp = Replace( tmp, "&#" & i & ";", chr( i ) )
Next
HTMLDecode = tmp
End Function
Function HTMLEncode(String1)
tmp = String1
tmp = Replace( tmp, chr(34), """ )
tmp = Replace( tmp, chr(60), "<" )
tmp = Replace( tmp, chr(62), ">" )
tmp = Replace( tmp, chr(38), "&" )
tmp = Replace( tmp, chr(32), " " )
For i = 1 to 255
tmp = Replace( tmp, chr( i ), "&#" & i & ";" )
Next
HTMLEncode = tmp
End Function

% >

String1

Views 1,962

Downloads 633

CodeID
DB ID