模块:UrlDecode

来自康健生活

使用lua进行url转码、解码。

UrlDecode 用于将中文汉字转码

使用方法:{{#invoke:UrlDecode|url|str={{fullurl:{{FULLPAGENAME}}}}}}


local p = {}
local function urlDecode(s)    
    s = string.gsub(s, '%%(%x%x)', function(h) 
    return string.char(tonumber(h, 16)) end)    
    return s
end

function p.url(frame)
	local str = frame.args.str
    return urlDecode(str)
end	
return p