Module:Latin
From The Goon Show Depository
local p = {}
function p._removeaccents(rv)
rv = mw.ustring.gsub(rv,"[ÁÀÂÄǍĂĀÃÅĄ]","A")
rv = mw.ustring.gsub(rv,"[ÆǢǼ]","Ae")
rv = mw.ustring.gsub(rv,"[ĆĊĈČÇ]","C")
rv = mw.ustring.gsub(rv,"[ĎĐḌÐḐ]","D")
rv = mw.ustring.gsub(rv,"[ÉÈĖÊËĚĔĒẼĘẸƐƎƏỀỂỄẾỆ]","E")
rv = mw.ustring.gsub(rv,"[ĠĜĞĢ]","G")
rv = mw.ustring.gsub(rv,"[ĤĦḤ]","H")
rv = mw.ustring.gsub(rv,"[İÍÌÎÏǏĬĪĨĮỊ]","I")
rv = mw.ustring.gsub(rv,"[Ĵ]","J")
rv = mw.ustring.gsub(rv,"[Ķ]","K")
rv = mw.ustring.gsub(rv,"[ĹĿĽĻŁḶḸ]","L")
rv = mw.ustring.gsub(rv,"[Ṃ]","M")
rv = mw.ustring.gsub(rv,"[ŃŇÑŅṆŊ]","N")
rv = mw.ustring.gsub(rv,"[ÓÒÔÖǑŎŌÕǪỌŐØƆ]","O")
rv = mw.ustring.gsub(rv,"[Œ]","Oe")
rv = mw.ustring.gsub(rv,"[ŔŘŖṚṜꝚⱤɌƦȐȒṘ]","R")
rv = mw.ustring.gsub(rv,"[ŚŜŠŞȘṢ]","S")
rv = mw.ustring.gsub(rv,"[ŤŢȚṬ]","T")
rv = mw.ustring.gsub(rv,"[Þ]","Th")
rv = mw.ustring.gsub(rv,"[ÚÙÛÜǓŬŪŨŮŲỤŰǗǛǙǕ]","U")
rv = mw.ustring.gsub(rv,"[Ŵ]","W")
rv = mw.ustring.gsub(rv,"[ÝŶŸỸȲ]","Y")
rv = mw.ustring.gsub(rv,"[ŹŻŽ]","Z")
rv = mw.ustring.gsub(rv,"[áàâäǎăāãåąắăằắẳẵặâầẩẫấậả]","a")
rv = mw.ustring.gsub(rv,"[æǣǽ]","ae")
rv = mw.ustring.gsub(rv,"[ćċĉčç]","c")
rv = mw.ustring.gsub(rv,"[ďđḍðḑ]","d")
rv = mw.ustring.gsub(rv,"[éèėêëěĕēẽęẹɛǝəềểễếệ]","e")
rv = mw.ustring.gsub(rv,"[ġĝğģ]","g")
rv = mw.ustring.gsub(rv,"[ĥħḥḩ]","h")
rv = mw.ustring.gsub(rv,"[ıíìîïǐĭīĩįị]","i")
rv = mw.ustring.gsub(rv,"[ĵ]","j")
rv = mw.ustring.gsub(rv,"[ķ]","k")
rv = mw.ustring.gsub(rv,"[ĺŀľļłḷḹ]","l")
rv = mw.ustring.gsub(rv,"[ṃ]","m")
rv = mw.ustring.gsub(rv,"[ńňñņṇŋ]","n")
rv = mw.ustring.gsub(rv,"[óòôöǒŏōõǫọőøɔơồ]","o")
rv = mw.ustring.gsub(rv,"[œ]","oe")
rv = mw.ustring.gsub(rv,"[ŕřŗṛṝꝛɽɍʀȑȓṙ]","r")
rv = mw.ustring.gsub(rv,"[śŝšşșṣ]","s")
rv = mw.ustring.gsub(rv,"[ß]","ss")
rv = mw.ustring.gsub(rv,"[ťţțṭ]","t")
rv = mw.ustring.gsub(rv,"[þ]","th")
rv = mw.ustring.gsub(rv,"[úùûüǔŭūũůųụűǘǜǚǖưứừ]","u")
rv = mw.ustring.gsub(rv,"[ŵ]","w")
rv = mw.ustring.gsub(rv,"[ýŷÿỹȳ]","y")
rv = mw.ustring.gsub(rv,"[źżž]","z")
return rv
end
function p.removeaccents(frame)
local rv = mw.ustring.toNFC (frame.args[1])
-- if (true) then return mw.ustring.isutf8 (rv) end
return p._removeaccents(rv)
end
--[[
The next function returns a % encoding concomitant with ISO/IEC 8859-1. It encodes % and any non-reserved and non-unreserved
characters.
Space is currently encoded as an underscore.
Reserved characters are currently not encoded.
]]
function p.urlencodeISO88591(frame)
local rv = mw.ustring.toNFC (frame.args[1])
-- % first to avoid double encoding
rv = mw.ustring.gsub(rv,"%%","%%%%")
-- space to underscore, then punctuation which is not reserved
rv = mw.ustring.gsub(rv," ","_")
rv = mw.ustring.gsub(rv,"\034;","%%22") -- quote mark
rv = mw.ustring.gsub(rv,"<","%%3C")
rv = mw.ustring.gsub(rv,">","%%3E")
rv = mw.ustring.gsub(rv,"\\","%%5C") -- backslash does not work with "\092", "%\" or "\"
rv = mw.ustring.gsub(rv,"%^","%%5E")
rv = mw.ustring.gsub(rv,"`","%%60")
rv = mw.ustring.gsub(rv,"{","%%7B")
rv = mw.ustring.gsub(rv,"|","%%7C")
rv = mw.ustring.gsub(rv,"}","%%7D")
-- all the rest of the codepoints that are printable
rv = mw.ustring.gsub(rv,"\194\160","%%A0")
rv = mw.ustring.gsub(rv,"\194\161","%%A1")
rv = mw.ustring.gsub(rv,"\194\162","%%A2")
rv = mw.ustring.gsub(rv,"\194\163","%%A3")
rv = mw.ustring.gsub(rv,"\194\164","%%A4")
rv = mw.ustring.gsub(rv,"\194\165","%%A5")
rv = mw.ustring.gsub(rv,"\194\166","%%A6")
rv = mw.ustring.gsub(rv,"\194\167","%%A7")
rv = mw.ustring.gsub(rv,"\194\168","%%A8")
rv = mw.ustring.gsub(rv,"\194\169","%%A9")
rv = mw.ustring.gsub(rv,"\194\170","%%AA")
rv = mw.ustring.gsub(rv,"\194\171","%%AB")
rv = mw.ustring.gsub(rv,"\194\172","%%AC")
rv = mw.ustring.gsub(rv,"\194\173","%%AD")
rv = mw.ustring.gsub(rv,"\194\174","%%AE")
rv = mw.ustring.gsub(rv,"\194\175","%%AF")
rv = mw.ustring.gsub(rv,"\194\176","%%B0")
rv = mw.ustring.gsub(rv,"\194\177","%%B1")
rv = mw.ustring.gsub(rv,"\194\178","%%B2")
rv = mw.ustring.gsub(rv,"\194\179","%%B3")
rv = mw.ustring.gsub(rv,"\194\180","%%B4")
rv = mw.ustring.gsub(rv,"\194\181","%%B5")
rv = mw.ustring.gsub(rv,"\194\182","%%B6")
rv = mw.ustring.gsub(rv,"\194\183","%%B7")
rv = mw.ustring.gsub(rv,"\194\184","%%B8")
rv = mw.ustring.gsub(rv,"\194\185","%%B9")
rv = mw.ustring.gsub(rv,"\194\186","%%BA")
rv = mw.ustring.gsub(rv,"\194\187","%%BB")
rv = mw.ustring.gsub(rv,"\194\188","%%BC")
rv = mw.ustring.gsub(rv,"\194\189","%%BD")
rv = mw.ustring.gsub(rv,"\194\190","%%BE")
rv = mw.ustring.gsub(rv,"\194\191","%%BF")
rv = mw.ustring.gsub(rv,"\195\128","%%C0")
rv = mw.ustring.gsub(rv,"\195\129","%%C1")
rv = mw.ustring.gsub(rv,"\195\130","%%C2")
rv = mw.ustring.gsub(rv,"\195\131","%%C3")
rv = mw.ustring.gsub(rv,"\195\132","%%C4")
rv = mw.ustring.gsub(rv,"\195\133","%%C5")
rv = mw.ustring.gsub(rv,"\195\134","%%C6")
rv = mw.ustring.gsub(rv,"\195\135","%%C7")
rv = mw.ustring.gsub(rv,"\195\136","%%C8")
rv = mw.ustring.gsub(rv,"\195\137","%%C9")
rv = mw.ustring.gsub(rv,"\195\138","%%CA")
rv = mw.ustring.gsub(rv,"\195\139","%%CB")
rv = mw.ustring.gsub(rv,"\195\140","%%CC")
rv = mw.ustring.gsub(rv,"\195\141","%%CD")
rv = mw.ustring.gsub(rv,"\195\142","%%CE")
rv = mw.ustring.gsub(rv,"\195\143","%%CF")
rv = mw.ustring.gsub(rv,"\195\144","%%D0")
rv = mw.ustring.gsub(rv,"\195\145","%%D1")
rv = mw.ustring.gsub(rv,"\195\146","%%D2")
rv = mw.ustring.gsub(rv,"\195\147","%%D3")
rv = mw.ustring.gsub(rv,"\195\148","%%D4")
rv = mw.ustring.gsub(rv,"\195\149","%%D5")
rv = mw.ustring.gsub(rv,"\195\150","%%D6")
rv = mw.ustring.gsub(rv,"\195\151","%%D7")
rv = mw.ustring.gsub(rv,"\195\152","%%D8")
rv = mw.ustring.gsub(rv,"\195\153","%%D9")
rv = mw.ustring.gsub(rv,"\195\154","%%DA")
rv = mw.ustring.gsub(rv,"\195\155","%%DB")
rv = mw.ustring.gsub(rv,"\195\156","%%DC")
rv = mw.ustring.gsub(rv,"\195\157","%%DD")
rv = mw.ustring.gsub(rv,"\195\158","%%DE")
rv = mw.ustring.gsub(rv,"\195\159","%%DF")
rv = mw.ustring.gsub(rv,"\195\160","%%E0")
rv = mw.ustring.gsub(rv,"\195\161","%%E1")
rv = mw.ustring.gsub(rv,"\195\162","%%E2")
rv = mw.ustring.gsub(rv,"\195\163","%%E3")
rv = mw.ustring.gsub(rv,"\195\164","%%E4")
rv = mw.ustring.gsub(rv,"\195\165","%%E5")
rv = mw.ustring.gsub(rv,"\195\166","%%E6")
rv = mw.ustring.gsub(rv,"\195\167","%%E7")
rv = mw.ustring.gsub(rv,"\195\168","%%E8")
rv = mw.ustring.gsub(rv,"\195\169","%%E9")
rv = mw.ustring.gsub(rv,"\195\170","%%EA")
rv = mw.ustring.gsub(rv,"\195\171","%%EB")
rv = mw.ustring.gsub(rv,"\195\172","%%EC")
rv = mw.ustring.gsub(rv,"\195\173","%%ED")
rv = mw.ustring.gsub(rv,"\195\174","%%EE")
rv = mw.ustring.gsub(rv,"\195\175","%%EF")
rv = mw.ustring.gsub(rv,"\195\176","%%F0")
rv = mw.ustring.gsub(rv,"\195\177","%%F1")
rv = mw.ustring.gsub(rv,"\195\178","%%F2")
rv = mw.ustring.gsub(rv,"\195\179","%%F3")
rv = mw.ustring.gsub(rv,"\195\180","%%F4")
rv = mw.ustring.gsub(rv,"\195\181","%%F5")
rv = mw.ustring.gsub(rv,"\195\182","%%F6")
rv = mw.ustring.gsub(rv,"\195\183","%%F7")
rv = mw.ustring.gsub(rv,"\195\184","%%F8")
rv = mw.ustring.gsub(rv,"\195\185","%%F9")
rv = mw.ustring.gsub(rv,"\195\186","%%FA")
rv = mw.ustring.gsub(rv,"\195\187","%%FB")
rv = mw.ustring.gsub(rv,"\195\188","%%FC")
rv = mw.ustring.gsub(rv,"\195\189","%%FD")
rv = mw.ustring.gsub(rv,"\195\190","%%FE")
rv = mw.ustring.gsub(rv,"\195\191","%%FF")
return rv
end
return p