local p = {}
local function get_all_codepoints(str)
local codepoint_set = {}
for codepoint in mw.ustring.gcodepoint(str) do
if codepoint > 0x7F then
codepoint_set[codepoint] = true
end
end
return require "Module:table".keysToList(codepoint_set)
end
function p.show()
local content = mw.title.new("MediaWiki:Gadget-charinsert-core.js"):getContent()
local charinsert = content:match("charinsert: (%b{})")
if not charinsert then return "Could not find charinsert" end
local codepoint_list = get_all_codepoints(charinsert)
local Unicode = require "Module:Unicode data"
local JSON = {}
local len = 0
for i, codepoint in ipairs(codepoint_list) do
local key_and_value = '"' .. codepoint .. '":"' .. Unicode.lookup_name(codepoint) .. '"'
if len + #key_and_value > 80 then
key_and_value = '\n' .. key_and_value
len = #key_and_value
else
len = len + #key_and_value
end
table.insert(JSON, key_and_value)
end
return "{" .. table.concat(JSON, ",") .. "}"
end
return p