local export = {}
local u = mw.ustring.char
local GRAVE     = u(0x0300)
local ACUTE     = u(0x0301)
local MACRON    = u(0x0304)

local remove_diacritics = GRAVE .. ACUTE .. MACRON

local cyrillic = {
	["[IlІӀ]"] = "ӏ", ["ᴴ"] = "ᵸ"
}

function export.makeEntryName(text, lang, sc)
	if sc == "Cyrl" then -- if script is Cyrillic, correct "false" palochkas and dialectal nasal ᵸ written as Latin ᴴ; not desirable if using another script
		for from, to in pairs(cyrillic) do
			text = mw.ustring.gsub(text, from, to)
		end
	end
	
	return mw.ustring.toNFC(mw.ustring.gsub(mw.ustring.toNFD(text), "[" .. remove_diacritics .. "]", "")) -- decompose, remove appropriate diacritics, then recompose again
end

return export