Created
August 17, 2017 14:02
-
-
Save muxueqz/0f0c21dda0c98fef802e462f96b809b7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function unescape(str) | |
str = string.gsub( str, '<', '<' ) | |
str = string.gsub( str, '>', '>' ) | |
str = string.gsub( str, '"', '"' ) | |
str = string.gsub( str, ''', "'" ) | |
str = string.gsub( str, '&#(%d+);', function(n) return string.char(n) end ) | |
str = string.gsub( str, '&#x(%d+);', function(n) return string.char(tonumber(n,16)) end ) | |
str = string.gsub( str, '&', '&' ) -- Be sure to do this after all others | |
return str | |
end | |
print(unescape(""Hello" 'World'")) --> "Hello" 'World' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment