Jump to content

Module:User:Erutuon/05

From Wiktionary, the free dictionary

ᾰ̓́γω (3 non-combining characters long), ἀθῡμῐ́ᾱ (6 non-combining characters long)


local export = {}

local isCombining = require("Module:Unicode data").is_combining

local function getLength(str)
	local length = 0
	for codepoint in mw.ustring.gcodepoint(str) do
		if not isCombining(codepoint) then
			length = length + 1
		end
	end
	return length
end

local function displayLength(str)
	return str .. " (" .. getLength(str) .. " non-combining characters long)"
end

function export.show(frame)
	local output = {}
	
	for i, arg in ipairs(frame.args or {}) do
		table.insert(output, displayLength(arg))
	end
	
	return table.concat(output, ", ")
end

return export