Kontent qismiga oʻtish

Modul:Encode

Vikipediya, ochiq ensiklopediya

}}


local function decode(t,cp,q)
return t:gsub('[^\x01-\x7f]',function(a)--do not use \x00 in patterns
	for k,v in pairs(cp) do
		if v==a then
			return k
		end;
	end
	return q
end)
end;

local function encode(t,cp,q)
return mw.ustring.gsub(t,'[^\x01-\x7f]',function(a)
	return cp[a] or q
end)
end;

return {
Encode=encode;
Decode=decode;
rawencode = function(frame)
return encode(frame.args[2],mw.loadData("Module:Encode/"..mw.text.trim(frame.args[1])),frame.args['q'])
end;
encode = function(frame)
return mw.uri.encode(encode(frame.args[2],mw.loadData("Module:Encode/"..mw.text.trim(frame.args[1])),frame.args['q']),frame.args.type or 'QUERY')
end;
decode = function(frame)
return decode(mw.uri.decode(frame.args[2],frame.args['type'] or "QUERY"),mw.loadData("Module:Encode/"..mw.text.trim(frame.args[1])),frame.args['q'])
end;
rawdecode = function(frame)
return decode(frame.args[2],mw.loadData("Module:Encode/"..mw.text.trim(frame.args[1])),frame.args['q'])
end
}