Documentation for this module may be created at မဝ်ဂျူ:StarLing/doc

local export = {}

-- StarLing isn't consistent about Unicode normalization. Some letters are
-- decomposed (NFD), others are composed (NFC).
function export.fix_unicode_and_url_encode(text)
	-- Decompose LATIN SMALL LETTER A WITH BREVE
	-- to LATIN SMALL LETTER A, COMBINING BREVE.
	text = text
		:gsub("ă", "a" .. mw.ustring.char(0x306))
		:gsub("Ă", "A" .. mw.ustring.char(0x306))
		:gsub("ĕ", "e" .. mw.ustring.char(0x306))
		:gsub("Ĕ", "E" .. mw.ustring.char(0x306))
		:gsub("ĭ", "i" .. mw.ustring.char(0x306))
		:gsub("Ĭ", "I" .. mw.ustring.char(0x306))
		:gsub("ŏ", "o" .. mw.ustring.char(0x306))
		:gsub("Ŏ", "O" .. mw.ustring.char(0x306))
		:gsub("ŭ", "u" .. mw.ustring.char(0x306))
		:gsub("Ŭ", "U" .. mw.ustring.char(0x306))
	
	return mw.uri.encode(text)
end

function export.fix_unicode_and_url_encode_frame(frame)
	return export.fix_unicode_and_url_encode(frame.args[1])
end

return export