Module:User:Theknightwho/DUCET

This is a private module sandbox of Theknightwho, for their own experimentation. Items in this module may be added and removed at Theknightwho's discretion; do not rely on this module's stability.


local u = mw.ustring.char

local ducet = mw.title.new("User:Theknightwho/Unicode/DUCET"):getContent()

local serial = {}

for line in ducet:gmatch("([^\n]+)%f[%z\n]") do
	if not line:find("^@") then
		for char in line:gmatch("[^ ]+") do
			if char == ";" then
				break
			else
				char = tonumber(char, 16)
				table.insert(serial, u(char))
			end
		end
		for type, w1, w2, w3 in line:gmatch("%[([%.%*])(%x+)%.(%x+)%.(%x+)%]") do
			if type == "*" then
				table.insert(serial, "\253")
			else
				table.insert(serial, "\254")
			end
			for _, w in ipairs{w1, w2, w3} do
				w = tonumber(w, 16)
				table.insert(serial, u(w))
			end
		end
		table.insert(serial, "\255")
	end
end

local ret = table.concat(serial)
ret = ret:gsub(".", function(m)
	return "\\" .. m:byte()
end)
return ret