This module fixes characters in headwords so that words can be looked up in StarLing.


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)
	text = mw.ustring.gsub(text, "[ăĕĭŏŭĂĔĬŎŬ]+", mw.ustring.toNFD)
	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