local a={}function a.upper(L)local I=a.UPPER_MAP L=L:upper()local R=""for a,X in utf8.graphemes(L)do local P=L:sub(a,X)if I[P]then P=I[P]end R=R..P end return R end function a.lower(L)local I=a.LOWER_MAP L=L:lower()local R=""for a,X in utf8.graphemes(L)do local P=L:sub(a,X)if I[P]then P=I[P]end R=R..P end return R end a.UPPER_MAP={["\195\160"]="\195\128";["\195\161"]="\195\129";["\195\162"]="\195\130",["\195\163"]="\195\131",["\195\164"]="\195\132",["\195\165"]="\195\133";["\195\166"]="\195\134";["\195\167"]="\195\135";["\195\168"]="\195\136",["\195\169"]="\195\137",["\195\170"]="\195\138",["\195\171"]="\195\139",["\195\172"]="\195\140";["\195\173"]="\195\141";["\195\174"]="\195\142",["\195\175"]="\195\143";["\195\176"]="\195\144",["\195\177"]="\195\145";["\195\178"]="\195\146",["\195\179"]="\195\147",["\195\180"]="\195\148";["\195\181"]="\195\149";["\195\182"]="\195\150";["\195\184"]="\195\152";["\195\185"]="\195\153";["\195\186"]="\195\154";["\195\187"]="\195\155",["\195\188"]="\195\156",["\195\189"]="\195\157";["\195\190"]="\195\158";["\196\129"]="\196\128",["\196\131"]="\196\130";["\196\133"]="\196\132";["\196\135"]="\196\134",["\196\137"]="\196\136",["\196\139"]="\196\138";["\196\141"]="\196\140",["\196\143"]="\196\142";["\196\145"]="\196\144",["\196\147"]="\196\146";["\196\149"]="\196\148",["\196\151"]="\196\150";["\196\153"]="\196\152";["\196\155"]="\196\154";["\196\157"]="\196\156";["\196\159"]="\196\158";["\196\161"]="\196\160",["\196\163"]="\196\162";["\196\165"]="\196\164";["\196\167"]="\196\166";["\196\169"]="\196\168";["\196\171"]="\196\170";["\196\173"]="\196\172",["\196\175"]="\196\174",["\196\177"]="\196\176",["\196\179"]="\196\178",["\196\181"]="\196\180",["\196\183"]="\196\182",["\196\186"]="\196\185",["\196\188"]="\196\187",["\196\190"]="\196\189",["\197\128"]="\196\191";["\197\130"]="\197\129",["\197\132"]="\197\131";["\197\134"]="\197\133";["\197\136"]="\197\135",["\197\139"]="\197\138";["\197\141"]="\197\140",["\197\143"]="\197\142",["\197\145"]="\197\144";["\197\147"]="\197\146";["\197\149"]="\197\148",["\197\151"]="\197\150";["\197\153"]="\197\152",["\197\155"]="\197\154",["\197\157"]="\197\156",["\197\159"]="\197\158",["\197\161"]="\197\160";["\197\163"]="\197\162";["\197\165"]="\197\164";["\197\167"]="\197\166",["\197\169"]="\197\168";["\197\171"]="\197\170",["\197\173"]="\197\172";["\197\175"]="\197\174",["\197\177"]="\197\176";["\197\179"]="\197\178";["\197\181"]="\197\180",["\197\183"]="\197\182";["\195\191"]="\197\184",["\197\186"]="\197\185";["\197\188"]="\197\187",["\197\190"]="\197\189";["\197\191"]="\197\191";["\198\128"]="\198\129",["\198\131"]="\198\130",["\198\133"]="\198\132",["\198\136"]="\198\135";["\198\140"]="\198\139";["\198\146"]="\198\145",["\198\153"]="\198\152";["\198\163"]="\198\162",["\198\161"]="\198\160"}a.LOWER_MAP={}for L,I in pairs(a.UPPER_MAP)do a.LOWER_MAP[I]=L end return a
--- UTF8 utility functions
-- @module UTF8

local lib = {}

function lib.upper(str)
	local UPPER_MAP = lib.UPPER_MAP
	str = str:upper()
	local newStr = ""
	for start, stop in utf8.graphemes(str) do
		local chr = str:sub(start, stop)
		if UPPER_MAP[chr] then
			chr = UPPER_MAP[chr]
		end
		newStr = newStr .. chr
	end
	return newStr
end

function lib.lower(str)
	local LOWER_MAP = lib.LOWER_MAP
	str = str:lower()
	local newStr = ""
	for start, stop in utf8.graphemes(str) do
		local chr = str:sub(start, stop)
		if LOWER_MAP[chr] then
			chr = LOWER_MAP[chr]
		end
		newStr = newStr .. chr
	end
	return newStr
end

lib.UPPER_MAP = {
	['à'] = 'À',
	['á'] = 'Á',
	['â'] = 'Â',
	['ã'] = 'Ã',
	['ä'] = 'Ä',
	['å'] = 'Å',
	['æ'] = 'Æ',
	['ç'] = 'Ç',
	['è'] = 'È',
	['é'] = 'É',
	['ê'] = 'Ê',
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