lightweight url decode encode
Posted: Sun Apr 05, 2015 3:22 am
Is there somewhere a lightweight url decode/encode lua code available..
i tried the following but they are too memory intensive
or
i tried the following but they are too memory intensive
Code: Select all
function urldecode(str)
str = string.gsub(str, "+", " ")
str = string.gsub(str, "%%(%x%x)", function(h) return string.char(tonumber(h, 16)) end)
str = string.gsub(str, "\r\n", "\n")
return str
end
or
Code: Select all
hex={}
for i=0,255 do
hex[string.format("%0x",i)]=string.char(i)
hex[string.format("%0X",i)]=string.char(i)
end
function decodeURI(s)
return (s:gsub('%%(%x%x)',hex))
end