Module:Unicode data/category/make explained

local p =

local function read_page(title) return mw.title.new(title):getContentend

function p.make_singles_and_ranges(derived_general_category_page, property_value_aliases_page) local text = read_page(derived_general_category_page) local singles, ranges =, for code_point1, code_point2, general_category in text:gmatch "%f[^\n%z](%x+)%.?%.?(%x*)%s*;%s*(%u%l)" do if general_category ~= "Cn" then code_point1 = tonumber(code_point1, 16) -- XXXX..XXXX ; gc if code_point2 ~= "" then code_point2 = tonumber(code_point2, 16) table.insert(ranges,) -- XXXX ; gc else singles[code_point1] = general_category end end end local property_value_aliases = read_page(property_value_aliases_page) local general_category_aliases = property_value_aliases:match "# General_Category[^\n]+%s*(.-)%s*%f[^\n]#" local long_names = for abbr, long_name in general_category_aliases:gmatch "gc%s*;%s*(%S+)%s*;%s*([%a_]+)" do long_names[abbr] = long_name end return singles, ranges, long_namesend

function p.print_data(data) local output = require "Module:array" local function writef(...) output:insert(string.format(...)) end writef