localexport={}localencoders={}encoders["ISO 8859-1"]=function(text)localret={}forcpinmw.ustring.gcodepoint(text)doifcp>=256thenerror("Invalid ISO 8859-1 character \""..mw.ustring.char(cp).."\".")endtable.insert(ret,string.char(cp))endreturntable.concat(ret)endfunctionexport.encode(text,encoding)iftype(text)=="table"thenlocalparams={[1]={required=true,allow_empty=true},[2]={required=true},}localargs=require("Module:parameters").process(text.args,params)text=args[1]encoding=args[2]endlocalencoder=encoders[encoding]ifnotencoderthenerror("No encoder exists for the encoding \""..encoding.."\".")endreturnmw.uri.encode(encoder(text))endreturnexport