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