lua URL解码
local function unescape(s)s = string.gsub(s,"+"," ")s = string.gsub(s,"%%(%x%x)",function(h)return string.char(tonumber(h,16))end)return s
endlocal cgi = {}
local function decode(s)for name,value in string.gmatch(s,"([^&=]+)=(^&=)+") doname = unescape(name)value = unescape(value)cgi[name] = valueend
end
local function escape(s)s = string.gsub(s,"[&=+%%%c]",function(c)return string.format("%%%02X",string.byte(c))end)s = string.gsub(s," ","+")return s
end
local function encode(t)local b = {}for k,v in pairs(t) dob[#b+1] = (escape(k).."="..escape(v))endreturn table.concat(b,"&")
end