模組:Grk-mar-entryname

維基詞典,自由的多語言詞典


local export = {}
local u = mw.ustring.char

local remove_diacritics = u(0x030C) .. u(0x0324) .. u(0x032E) -- caron, diaeresis below, breve below

function export.makeEntryName(text, lang, sc)
	text = mw.ustring.toNFD(text) -- decompose
	if sc == "Cyrl" then -- if script is Cyrillic, remove acute accents
		text = mw.ustring.gsub(text, "[" .. u(0x0301) .. "]", "")
	end
	
	return mw.ustring.toNFC(mw.ustring.gsub(text, "[" .. remove_diacritics .. "]", "")) -- remove appropriate diacritics, then recompose again
end

return export