Saltu al enhavo

Modulo:Utf8ToAnsi

El Vikivortaro
 MODULO
Memtesto ne disponeblas.

local export = {}

-- this function enables the module to be called from a template
function export.main(frame)
	if type(export[frame.args[1]]) == 'function' then
		return export[frame.args[1]](frame.args[2], frame.args[3])
	else
		return export[frame.args[1]][frame.args[2]]
	end
end

function export.convert_diacritics(word)
	word = mw.ustring.gsub(word, "ª", "%%AA")
	word = mw.ustring.gsub(word, "à", "%%E0")
	word = mw.ustring.gsub(word, "À", "%%C0")
	word = mw.ustring.gsub(word, "á", "%%E1")
	word = mw.ustring.gsub(word, "Á", "%%C1")
	word = mw.ustring.gsub(word, "â", "%%E2")
	word = mw.ustring.gsub(word, "Â", "%%C2")
	word = mw.ustring.gsub(word, "ã", "%%E3")
	word = mw.ustring.gsub(word, "Ã", "%%C3")
	word = mw.ustring.gsub(word, "ä", "%%E4")
	word = mw.ustring.gsub(word, "Ä", "%%C4")
	word = mw.ustring.gsub(word, "ç", "%%E7")
	word = mw.ustring.gsub(word, "Ç", "%%C7")
	word = mw.ustring.gsub(word, "č", "%%E8")
	word = mw.ustring.gsub(word, "Č", "%%C8")
	word = mw.ustring.gsub(word, "ď", "%%EF")
	word = mw.ustring.gsub(word, "è", "%%E8")
	word = mw.ustring.gsub(word, "È", "%%C8")
	word = mw.ustring.gsub(word, "é", "%%E9")
	word = mw.ustring.gsub(word, "É", "%%C9")
	word = mw.ustring.gsub(word, "ê", "%%EA")
	word = mw.ustring.gsub(word, "Ê", "%%CA")
	word = mw.ustring.gsub(word, "ě", "%%EC")
	word = mw.ustring.gsub(word, "ì", "%%EC")
	word = mw.ustring.gsub(word, "Ì", "%%CC")
	word = mw.ustring.gsub(word, "í", "%%ED")
	word = mw.ustring.gsub(word, "Í", "%%CD")
	word = mw.ustring.gsub(word, "î", "%%EE")
	word = mw.ustring.gsub(word, "Î", "%%CE")
	word = mw.ustring.gsub(word, "ñ", "%%F1")
	word = mw.ustring.gsub(word, "ň", "%%F2")
	word = mw.ustring.gsub(word, "ò", "%%F2")
	word = mw.ustring.gsub(word, "Ò", "%%D2")
	word = mw.ustring.gsub(word, "ó", "%%F3")
	word = mw.ustring.gsub(word, "Ó", "%%D3")
	word = mw.ustring.gsub(word, "ô", "%%F4")
	word = mw.ustring.gsub(word, "Ô", "%%D4")
	word = mw.ustring.gsub(word, "ö", "%%F6")
	word = mw.ustring.gsub(word, "Ö", "%%D6")
	word = mw.ustring.gsub(word, "ř", "%%F8")
	word = mw.ustring.gsub(word, "Ř", "%%D8")
	word = mw.ustring.gsub(word, "š", "%%9A")
	word = mw.ustring.gsub(word, "Š", "%%8A")
	word = mw.ustring.gsub(word, "ť", "%%9D")
	word = mw.ustring.gsub(word, "ù", "%%F9")
	word = mw.ustring.gsub(word, "ů", "%%F9")
	word = mw.ustring.gsub(word, "Ù", "%%D9")
	word = mw.ustring.gsub(word, "ú", "%%FA")
	word = mw.ustring.gsub(word, "Ú", "%%DA")
	word = mw.ustring.gsub(word, "û", "%%FB")
	word = mw.ustring.gsub(word, "Û", "%%DB")
	word = mw.ustring.gsub(word, "ü", "%%FC")
	word = mw.ustring.gsub(word, "Ü", "%%DC")
	word = mw.ustring.gsub(word, "ý", "%%FD")
	word = mw.ustring.gsub(word, "ž", "%%9E")
	word = mw.ustring.gsub(word, "ß", "%%DF")

	return word
end

function export.convert_diacritics_plus(word) --Vorlage:Ref-UniLeipzig
	word = mw.ustring.gsub(word, " ", "+")
	word = mw.ustring.gsub(word, "ª", "%%AA")
	word = mw.ustring.gsub(word, "à", "%%E0")
	word = mw.ustring.gsub(word, "À", "%%C0")
	word = mw.ustring.gsub(word, "á", "%%E1")
	word = mw.ustring.gsub(word, "Á", "%%C1")
	word = mw.ustring.gsub(word, "â", "%%E2")
	word = mw.ustring.gsub(word, "Â", "%%C2")
	word = mw.ustring.gsub(word, "ã", "%%E3")
	word = mw.ustring.gsub(word, "Ã", "%%C3")
	word = mw.ustring.gsub(word, "ä", "%%E4")
	word = mw.ustring.gsub(word, "Ä", "%%C4")
	word = mw.ustring.gsub(word, "ç", "%%E7")
	word = mw.ustring.gsub(word, "Ç", "%%C7")
	word = mw.ustring.gsub(word, "č", "%%E8")
	word = mw.ustring.gsub(word, "Č", "%%C8")
	word = mw.ustring.gsub(word, "ď", "%%EF")
	word = mw.ustring.gsub(word, "è", "%%E8")
	word = mw.ustring.gsub(word, "È", "%%C8")
	word = mw.ustring.gsub(word, "é", "%%E9")
	word = mw.ustring.gsub(word, "É", "%%C9")
	word = mw.ustring.gsub(word, "ê", "%%EA")
	word = mw.ustring.gsub(word, "Ê", "%%CA")
	word = mw.ustring.gsub(word, "ě", "%%EC")
	word = mw.ustring.gsub(word, "ì", "%%EC")
	word = mw.ustring.gsub(word, "Ì", "%%CC")
	word = mw.ustring.gsub(word, "í", "%%ED")
	word = mw.ustring.gsub(word, "Í", "%%CD")
	word = mw.ustring.gsub(word, "î", "%%EE")
	word = mw.ustring.gsub(word, "Î", "%%CE")
	word = mw.ustring.gsub(word, "ñ", "%%F1")
	word = mw.ustring.gsub(word, "ň", "%%F2")
	word = mw.ustring.gsub(word, "ò", "%%F2")
	word = mw.ustring.gsub(word, "Ò", "%%D2")
	word = mw.ustring.gsub(word, "ó", "%%F3")
	word = mw.ustring.gsub(word, "Ó", "%%D3")
	word = mw.ustring.gsub(word, "ô", "%%F4")
	word = mw.ustring.gsub(word, "Ô", "%%D4")
	word = mw.ustring.gsub(word, "ö", "%%F6")
	word = mw.ustring.gsub(word, "Ö", "%%D6")
	word = mw.ustring.gsub(word, "ř", "%%F8")
	word = mw.ustring.gsub(word, "Ř", "%%D8")
	word = mw.ustring.gsub(word, "š", "%%9A")
	word = mw.ustring.gsub(word, "Š", "%%8A")
	word = mw.ustring.gsub(word, "ť", "%%9D")
	word = mw.ustring.gsub(word, "ù", "%%F9")
	word = mw.ustring.gsub(word, "ů", "%%F9")
	word = mw.ustring.gsub(word, "Ù", "%%D9")
	word = mw.ustring.gsub(word, "ú", "%%FA")
	word = mw.ustring.gsub(word, "Ú", "%%DA")
	word = mw.ustring.gsub(word, "û", "%%FB")
	word = mw.ustring.gsub(word, "Û", "%%DB")
	word = mw.ustring.gsub(word, "ü", "%%FC")
	word = mw.ustring.gsub(word, "Ü", "%%DC")
	word = mw.ustring.gsub(word, "ý", "%%FD")
	word = mw.ustring.gsub(word, "ž", "%%9E")
	word = mw.ustring.gsub(word, "ß", "%%DF")
	word = mw.ustring.gsub(word, "*", "%%2A") -- -bräu

	return word
end

function export.convert_e_to_c495(word) --Buchstabe ě in Vorlage:Ref-Langenscheidt|cs

	word = mw.ustring.gsub(word, "ě", "%%C4%%95")
	
	return word
end

return export