Title: Module:Unicode data - freem URL Source: https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data Markdown Content: [Jump to content](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#bodyContent) - [x] Main menu Main menu move to sidebar hide Navigation * [Main page](https://freemwiki.com/wiki/Main_Page "Visit the main page [alt-shift-z]") * [Recent changes](https://freemwiki.com/wiki/Special:RecentChanges "A list of recent changes in the wiki [alt-shift-r]") * [Random page](https://freemwiki.com/wiki/Special:Random "Load a random page [alt-shift-x]") * [Help about MediaWiki](https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents) Legal * [Terms](https://freemwiki.com/wiki/Terms_of_Service) * [Privacy Policy](https://freemwiki.com/wiki/Privacy_Policy) * [About](https://freemwiki.com/wiki/About) * [Contact](https://freemwiki.com/wiki/Contact) [![Image 1](https://freemwiki.com/images/freem.svg)**freem**](https://freemwiki.com/wiki/Main_Page) [Search](https://freemwiki.com/wiki/Special:Search "Search freem [alt-shift-f]") Search - [x] Appearance * [Create account](https://freemwiki.com/index.php?title=Special:CreateAccount&returnto=Module%3AUnicode+data&returntoquery=oldid%3D579706 "You are encouraged to create an account and log in; however, it is not mandatory") * [Log in](https://freemwiki.com/index.php?title=Special:UserLogin&returnto=Module%3AUnicode+data&returntoquery=oldid%3D579706 "You are encouraged to log in; however, it is not mandatory [alt-shift-o]") - [x] Personal tools * [Create account](https://freemwiki.com/index.php?title=Special:CreateAccount&returnto=Module%3AUnicode+data&returntoquery=oldid%3D579706 "You are encouraged to create an account and log in; however, it is not mandatory") * [Log in](https://freemwiki.com/index.php?title=Special:UserLogin&returnto=Module%3AUnicode+data&returntoquery=oldid%3D579706 "You are encouraged to log in; however, it is not mandatory [alt-shift-o]") Pages for logged out editors [learn more](https://freemwiki.com/wiki/Help:Introduction) * [Contributions](https://freemwiki.com/wiki/Special:MyContributions "A list of edits made from this IP address [alt-shift-y]") * [Talk](https://freemwiki.com/wiki/Special:MyTalk "Discussion about edits from this IP address [alt-shift-n]") # Module:Unicode data - [x] Add languages * [Module](https://freemwiki.com/wiki/Module:Unicode_data "View the module page [alt-shift-c]") * [Discussion](https://freemwiki.com/index.php?title=Module_talk:Unicode_data&action=edit&redlink=1 "Discussion about the content page (page does not exist) [alt-shift-t]") - [x] English * [Read](https://freemwiki.com/wiki/Module:Unicode_data) * [Edit source](https://freemwiki.com/index.php?title=Module:Unicode_data&action=edit "Edit the source code of this page [alt-shift-e]") * [View history](https://freemwiki.com/index.php?title=Module:Unicode_data&action=history "Past revisions of this page [alt-shift-h]") - [x] Tools Tools move to sidebar hide Actions * [Read](https://freemwiki.com/wiki/Module:Unicode_data) * [Edit source](https://freemwiki.com/index.php?title=Module:Unicode_data&action=edit "Edit the source code of this page [alt-shift-e]") * [View history](https://freemwiki.com/index.php?title=Module:Unicode_data&action=history) General * [What links here](https://freemwiki.com/wiki/Special:WhatLinksHere/Module:Unicode_data "A list of all wiki pages that link here [alt-shift-j]") * [Related changes](https://freemwiki.com/wiki/Special:RecentChangesLinked/Module:Unicode_data "Recent changes in pages linked from this page [alt-shift-k]") * [Special pages](https://freemwiki.com/wiki/Special:SpecialPages "A list of all special pages [alt-shift-q]") * [Printable version](javascript:print(); "Printable version of this page [alt-shift-p]") * [Permanent link](https://freemwiki.com/index.php?title=Module:Unicode_data&oldid=579706 "Permanent link to this revision of this page") * [Page information](https://freemwiki.com/index.php?title=Module:Unicode_data&action=info "More information about this page") Appearance move to sidebar hide From freem Revision as of 06:18, 21 October 2025 by [Lukegao](https://freemwiki.com/index.php?title=User:Lukegao&action=edit&redlink=1 "User:Lukegao (page does not exist)")([talk](https://freemwiki.com/index.php?title=User_talk:Lukegao&action=edit&redlink=1 "User talk:Lukegao (page does not exist)") | [contribs](https://freemwiki.com/wiki/Special:Contributions/Lukegao "Special:Contributions/Lukegao"))(1 revision imported) ([diff](https://freemwiki.com/index.php?title=Module:Unicode_data&diff=prev&oldid=579706 "Module:Unicode data")) [← Older revision](https://freemwiki.com/index.php?title=Module:Unicode_data&direction=prev&oldid=579706 "Module:Unicode data") | Latest revision (diff) | Newer revision → (diff) _Documentation for this module may be created at [Module:Unicode data/doc](https://freemwiki.com/index.php?title=Module:Unicode\_data/doc&action=edit&redlink=1 "Module:Unicode data/doc (page does not exist)")_ [](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-1)local p = {}[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-2)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-3)local floor = math.floor[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-4)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-5)local function errorf(level, ...)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-6)if type(level) == "number" then[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-7)return error(string.format(...), level + 1)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-8)else -- level is actually the format string.[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-9)return error(string.format(level, ...), 2)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-10)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-11)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-12)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-13)local function binary_range_search(codepoint, ranges)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-14)local low, mid, high[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-15)low, high = 1, ranges.length or require "Module:TableTools".length(ranges)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-16)while low <= high do[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-17)mid = floor((low + high) / 2)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-18)local range = ranges[mid][](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-19)if codepoint < range[1] then[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-20)high = mid - 1[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-21)elseif codepoint <= range[2] then[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-22)return range, mid[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-23)else[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-24)low = mid + 1[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-25)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-26)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-27)return nil, mid[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-28)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-29)p.binary_range_search = binary_range_search[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-30)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-31)--[[[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-32)local function linear_range_search(codepoint, ranges)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-33) for i, range in ipairs(ranges) do[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-34) if range[1] <= codepoint and codepoint <= range[2] then[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-35) return range[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-36) end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-37) end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-38)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-39)--]][](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-40)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-41)-- Load a module by indexing "loader" with the name of the module minus the[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-42)-- "Module:Unicode data/" part. For instance, loader.blocks returns[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-43)-- [[[Module:Unicode data/blocks]]](https://freemwiki.com/wiki/Module:Unicode_data/blocks "Module:Unicode data/blocks"). If a module cannot be loaded, false will be[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-44)-- returned.[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-45)local loader = setmetatable({}, {[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-46)__index = function (self, key)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-47)local success, data = pcall(mw.loadData, "Module:Unicode data/" .. key)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-48)if not success then[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-49)data = false[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-50)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-51)self[key] = data[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-52)return data[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-53)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-54)})[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-55)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-56)-- For the algorithm used to generate Hangul Syllable names,[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-57)-- see "Hangul Syllable Name Generation" in section 3.12 of the[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-58)-- Unicode Specification:[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-59)-- [https://www.unicode.org/versions/Unicode11.0.0/ch03.pdf](https://www.unicode.org/versions/Unicode11.0.0/ch03.pdf)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-60)-- binary_range_search assumes these are ordered by codepoint. Do not place them in a random order![](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-61)local name_hooks = {[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-62){ 0x00, 0x1F, "" }, -- C0 control characters[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-63){ 0x7F, 0x9F, "" }, -- DEL and C1 control characters[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-64){ 0x3400, 0x4DBF, "CJK UNIFIED IDEOGRAPH-%04X" }, -- CJK Ideograph Extension A[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-65){ 0x4E00, 0x9FFF, "CJK UNIFIED IDEOGRAPH-%04X" }, -- CJK Ideograph[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-66){ 0xAC00, 0xD7A3, function (codepoint) -- Hangul Syllables[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-67)local Hangul_data = loader.Hangul[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-68)local syllable_index = codepoint - 0xAC00[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-69)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-70)return ("HANGUL SYLLABLE %s%s%s"):format([](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-71)Hangul_data.leads[floor(syllable_index / Hangul_data.final_count)],[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-72)Hangul_data.vowels[floor((syllable_index % Hangul_data.final_count)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-73)/ Hangul_data.trail_count)],[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-74)Hangul_data.trails[syllable_index % Hangul_data.trail_count][](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-75))[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-76)end },[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-77)-- High Surrogates, High Private Use Surrogates, Low Surrogates[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-78){ 0xD800, 0xDFFF, "" },[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-79){ 0xE000, 0xF8FF, "" }, -- Private Use[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-80)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-81)-- CJK Compatibility Ideographs[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-82){ 0xF900, 0xFA6D, "CJK COMPATIBILITY IDEOGRAPH-%04X" },[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-83){ 0xFA70, 0xFAD9, "CJK COMPATIBILITY IDEOGRAPH-%04X" },[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-84){ 0xFE00, 0xFE0F, function (codepoint) -- Variation Selectors[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-85)return ("VARIATION SELECTOR-%d"):format(codepoint - 0xFE00 + 1)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-86)end},[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-87){ 0x13460, 0x143FA, "EGYPTIAN HIEROGLYPH-%04X" }, -- Egyptian Hieroglyphs Extended-A[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-88){ 0x17000, 0x187FF, "TANGUT IDEOGRAPH-%04X" }, -- Tangut Ideograph[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-89){ 0x18800, 0x18AFF, function (codepoint)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-90)return ("TANGUT COMPONENT-%03d"):format(codepoint - 0x187FF)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-91)end },[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-92){ 0x18B00, 0x18CD5, "KHITAN SMALL SCRIPT CHARACTER-%04X" }, -- Khitan Small Script[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-93){ 0x18CFF, 0x18CFF, "KHITAN SMALL SCRIPT CHARACTER-%04X" }, -- Khitan Small Script[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-94){ 0x18D00, 0x18D1E, "TANGUT IDEOGRAPH-%04X" }, -- Tangut Ideograph Supplement[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-95){ 0x18D80, 0x18DF2, function (codepoint)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-96)return ("TANGUT COMPONENT-%03d"):format(codepoint - 0x18A7F)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-97)end },[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-98){ 0x1B170, 0x1B2FB, "NUSHU CHARACTER-%04X" }, -- Nushu[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-99){ 0x20000, 0x2A6DF, "CJK UNIFIED IDEOGRAPH-%04X" }, -- CJK Ideograph Extension B[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-100){ 0x2A700, 0x2B81D, "CJK UNIFIED IDEOGRAPH-%04X" }, -- CJK Ideograph Extension C, D[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-101){ 0x2B820, 0x2CEAD, "CJK UNIFIED IDEOGRAPH-%04X" }, -- CJK Ideograph Extension E[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-102){ 0x2CEB0, 0x2EBE0, "CJK UNIFIED IDEOGRAPH-%04X" }, -- CJK Ideograph Extension F[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-103){ 0x2EBF0, 0x2EE5D, "CJK UNIFIED IDEOGRAPH-%04X" }, -- CJK Ideograph Extension I[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-104){ 0x2F800, 0x2FA1D, "CJK COMPATIBILITY IDEOGRAPH-%04X" }, -- CJK Compatibility Ideographs Supplement (Supplementary Ideographic Plane)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-105){ 0x30000, 0x3134A, "CJK UNIFIED IDEOGRAPH-%04X" }, -- CJK Ideograph Extension G[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-106){ 0x31350, 0x33479, "CJK UNIFIED IDEOGRAPH-%04X" }, -- CJK Ideograph Extension H, J[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-107){ 0xE0100, 0xE01EF, function (codepoint) -- Variation Selectors Supplement[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-108)return ("VARIATION SELECTOR-%d"):format(codepoint - 0xE0100 + 17)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-109)end},[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-110){ 0xF0000, 0xFFFFD, "" }, -- Plane 15 Private Use[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-111){ 0x100000, 0x10FFFD, "" } -- Plane 16 Private Use[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-112)}[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-113)name_hooks.length = #name_hooks[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-114)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-115)local name_range_cache[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-116)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-117)local function generate_name(data, codepoint)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-118)if type(data) == "string" then[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-119)return data:format(codepoint)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-120)else[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-121)return data(codepoint)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-122)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-123)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-124)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-125)--[[[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-126)-- Checks that the code point is a number and in range.[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-127)-- Does not check whether code point is an integer.[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-128)-- Not used[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-129)local function check_codepoint(funcName, argIdx, val)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-130) require 'libraryUtil'.checkType(funcName, argIdx, val, 'number')[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-131) if codepoint < 0 or 0x10FFFF < codepoint then[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-132) errorf("Codepoint %04X out of range", codepoint)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-133) end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-134)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-135)--]][](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-136)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-137)function p.is_noncharacter(codepoint)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-138)-- U+FDD0-U+FDEF and all code points ending in FFFE or FFFF are Unassigned[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-139)-- (Cn) and specifically noncharacters:[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-140)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-141)-- [https://www.unicode.org/faq/private_use.html#nonchar4](https://www.unicode.org/faq/private_use.html#nonchar4)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-142)return 0xFDD0 <= codepoint and (codepoint <= 0xFDEF[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-143)or floor(codepoint % 0x10000) >= 0xFFFE)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-144)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-145)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-146)-- [https://www.unicode.org/versions/Unicode11.0.0/ch04.pdf](https://www.unicode.org/versions/Unicode11.0.0/ch04.pdf), section 4.8[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-147)function p.lookup_name(codepoint)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-148)if p.is_noncharacter(codepoint) then[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-149)return (""):format(codepoint)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-150)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-151)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-152)if name_range_cache -- Check if previously used "name hook" applies to this code point.[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-153)and codepoint >= name_range_cache[1][](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-154)and codepoint <= name_range_cache[2] then[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-155)return generate_name(name_range_cache[3], codepoint)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-156)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-157)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-158)local range = binary_range_search(codepoint, name_hooks)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-159)if range then[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-160)name_range_cache = range[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-161)return generate_name(range[3], codepoint)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-162)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-163)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-164)local data = loader[('names/%03X'):format(codepoint / 0x1000)][](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-165)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-166)if data and data[codepoint] then[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-167)return data[codepoint][](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-168)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-169)-- Unassigned (Cn) consists of noncharacters and reserved characters.[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-170)-- The character has been established not to be a noncharacter,[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-171)-- and if it were assigned, its name would already been retrieved,[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-172)-- so it must be reserved.[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-173)else[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-174)return (""):format(codepoint)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-175)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-176)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-177)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-178)function p.lookup_image(codepoint)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-179)local data = loader[('images/%03X'):format(codepoint / 0x1000)][](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-180)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-181)if data then[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-182)return data[codepoint][](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-183)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-184)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-185)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-186)local planes = {[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-187)[ 0] = "Basic Multilingual Plane";[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-188)[ 1] = "Supplementary Multilingual Plane";[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-189)[ 2] = "Supplementary Ideographic Plane";[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-190)[ 3] = "Tertiary Ideographic Plane";[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-191)[14] = "Supplementary Special-purpose Plane";[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-192)[15] = "Supplementary Private Use Area-A";[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-193)[16] = "Supplementary Private Use Area-B";[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-194)}[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-195)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-196)-- Load [[[Module:Unicode data/blocks]]](https://freemwiki.com/wiki/Module:Unicode_data/blocks "Module:Unicode data/blocks") if needed and assign it to this variable.[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-197)local blocks[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-198)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-199)local function block_iter(blocks, i)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-200)i = i + 1[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-201)local data = blocks[i][](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-202)if data then[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-203) -- Unpack doesn't work on tables loaded with mw.loadData.[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-204)return i, data[1], data[2], data[3][](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-205)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-206)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-207)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-208)-- An ipairs-type iterator generator for the list of blocks.[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-209)function p.enum_blocks()[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-210)local blocks = loader.blocks[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-211)return block_iter, blocks, 0[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-212)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-213)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-214)function p.lookup_plane(codepoint)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-215)local i = floor(codepoint / 0x10000)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-216)return planes[i] or ("Plane %u"):format(i)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-217)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-218)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-219)function p.lookup_block(codepoint)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-220)local blocks = loader.blocks[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-221)local range = binary_range_search(codepoint, blocks)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-222)if range then[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-223)return range[3][](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-224)else[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-225)return "No Block"[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-226)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-227)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-228)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-229)function p.get_block_info(name)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-230)for i, block in ipairs(loader.blocks) do[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-231)if block[3] == name then[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-232)return block[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-233)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-234)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-235)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-236)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-237)function p.is_valid_pagename(pagename)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-238)local has_nonws = false[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-239)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-240)for cp in mw.ustring.gcodepoint(pagename) do[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-241)if (cp == 0x0023) -- #[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-242)or (cp == 0x005B) -- [[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-243)or (cp == 0x005D) -- ][](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-244)or (cp == 0x007B) -- {[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-245)or (cp == 0x007C) -- |[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-246)or (cp == 0x007D) -- }[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-247)or (cp == 0x180E) -- MONGOLIAN VOWEL SEPARATOR[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-248)or ((cp >= 0x2000) and (cp <= 0x200A)) -- spaces in General Punctuation block[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-249)or (cp == 0xFFFD) -- REPLACEMENT CHARACTER[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-250)then[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-251)return false[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-252)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-253)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-254)local printable, result = p.is_printable(cp)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-255)if not printable then[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-256)return false[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-257)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-258)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-259)if result ~= "space-separator" then[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-260)has_nonws = true[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-261)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-262)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-263)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-264)return has_nonws[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-265)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-266)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-267)local function manual_unpack(what, from)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-268)if what[from + 1] == nil then[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-269)return what[from][](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-270)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-271)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-272)local result = {}[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-273)from = from or 1[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-274)for i, item in ipairs(what) do[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-275)if i >= from then[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-276)table.insert(result, item)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-277)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-278)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-279)return unpack(result)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-280)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-281)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-282)local function compare_ranges(range1, range2)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-283)return range1[1] < range2[1][](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-284)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-285)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-286)-- Creates a function to look up data in a module that contains "singles" (a[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-287)-- code point-to-data map) and "ranges" (an array containing arrays that contain[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-288)-- the low and high code points of a range and the data associated with that[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-289)-- range).[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-290)-- "loader" loads and returns the "singles" and "ranges" tables.[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-291)-- "match_func" is passed the code point and either the data or the "dots", and[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-292)-- generates the final result of the function.[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-293)-- The varargs ("dots") describes the default data to be returned if there wasn't[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-294)-- a match.[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-295)-- In case the function is used more than once, "cache" saves ranges that have[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-296)-- already been found to match, or a range whose data is the default if there[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-297)-- was no match.[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-298)local function memo_lookup(data_module_subpage, match_func, ...)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-299)local dots = { ... }[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-300)local cache = {}[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-301)local singles, ranges[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-302)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-303)return function (codepoint)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-304)if not singles then[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-305)local data_module = loader[data_module_subpage][](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-306)singles, ranges = data_module.singles, data_module.ranges[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-307)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-308)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-309)if singles[codepoint] then[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-310)return match_func(codepoint, singles[codepoint])[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-311)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-312)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-313)local range = binary_range_search(codepoint, cache)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-314)if range then[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-315)return match_func(codepoint, manual_unpack(range, 3))[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-316)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-317)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-318)local range, index = binary_range_search(codepoint, ranges)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-319)if range then[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-320)table.insert(cache, range)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-321)table.sort(cache, compare_ranges)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-322)return match_func(codepoint, manual_unpack(range, 3))[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-323)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-324)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-325)if ranges[index] then[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-326)local dots_range[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-327)if codepoint > ranges[index][2] then[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-328)dots_range = {[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-329)ranges[index][2] + 1,[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-330)ranges[index + 1] and ranges[index + 1][1] - 1 or 0x10FFFF,[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-331)unpack(dots)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-332)}[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-333)else -- codepoint < range[index][1][](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-334)dots_range = {[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-335)ranges[index - 1] and ranges[index - 1][2] + 1 or 0,[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-336)ranges[index][1] - 1,[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-337)unpack(dots)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-338)}[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-339)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-340)table.sort(cache, compare_ranges)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-341)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-342)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-343)return match_func(codepoint)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-344)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-345)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-346)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-347)-- Get a code point's combining class value in [[[Module:Unicode data/combining]]](https://freemwiki.com/wiki/Module:Unicode_data/combining "Module:Unicode data/combining"),[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-348)-- and return whether this value is not zero. Zero is assigned as the default[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-349)-- if the combining class value is not found in this data module.[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-350)-- That is, return true if character is combining, or false if it is not.[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-351)-- See [https://www.unicode.org/reports/tr44/#Canonical_Combining_Class_Values](https://www.unicode.org/reports/tr44/#Canonical_Combining_Class_Values) for[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-352)-- more information.[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-353)p.is_combining = memo_lookup([](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-354)"combining",[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-355)function (codepoint, combining_class)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-356)return combining_class and combining_class ~= 0 or false[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-357)end,[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-358)0)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-359)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-360)function p.add_dotted_circle(str)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-361)return (mw.ustring.gsub(str, ".",[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-362)function(char)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-363)if p.is_combining(mw.ustring.codepoint(char)) then[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-364)return '◌' .. char[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-365)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-366)end))[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-367)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-368)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-369)local lookup_control = memo_lookup([](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-370)"control",[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-371)function (codepoint, ccc)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-372)return ccc or "assigned"[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-373)end,[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-374)"assigned")[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-375)p.lookup_control = lookup_control[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-376)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-377)function p.is_assigned(codepoint)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-378)return lookup_control(codepoint) ~= "unassigned"[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-379)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-380)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-381)function p.is_printable(codepoint)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-382)local result = lookup_control(codepoint)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-383)return (result == "assigned") or (result == "space-separator"), result[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-384)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-385)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-386)function p.is_whitespace(codepoint)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-387)local result = lookup_control(codepoint)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-388)return (result == "space-separator"), result[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-389)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-390)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-391)p.lookup_category = memo_lookup([](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-392)"category",[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-393)function (codepoint, category)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-394)return category[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-395)end,[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-396)"Cn")[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-397)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-398)local lookup_script = memo_lookup([](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-399)"scripts",[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-400)function (codepoint, script_code)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-401)return script_code or 'Zzzz'[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-402)end,[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-403)"Zzzz")[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-404)p.lookup_script = lookup_script[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-405)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-406)function p.get_best_script(str)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-407)-- Check type of argument, because mw.text.decode coerces numbers to strings![](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-408)require "libraryUtil".checkType("get_best_script", 1, str, "string")[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-409)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-410)-- Convert HTML character references (including named character references,[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-411)-- or character entities) to characters.[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-412)str = mw.text.decode(str, true)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-413)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-414)local scripts = {}[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-415)for codepoint in mw.ustring.gcodepoint(str) do[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-416)local script = lookup_script(codepoint)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-417)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-418)-- Ignore "Inherited", "Undetermined", or "Uncoded" scripts.[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-419)if not (script == "Zyyy" or script == "Zinh" or script == "Zzzz") then[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-420)scripts[script] = true[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-421)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-422)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-423)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-424)-- If scripts does not contain two or more keys,[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-425)-- return first and only key (script code) in table.[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-426)if not next(scripts, next(scripts)) then[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-427)return next(scripts)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-428)end -- else return majority script, or else "Zzzz"?[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-429)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-430)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-431)function p.is_Latin(str)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-432)require "libraryUtil".checkType("get_best_script", 1, str, "string")[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-433)str = mw.text.decode(str, true)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-434)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-435)-- Search for the leading bytes that introduce the UTF-8 encoding of the[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-436)-- code points U+0340-U+10FFFF. If they are not found and there is at least[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-437)-- one Latin-script character, the string counts as Latin, because the rest[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-438)-- of the characters can only be Zyyy, Zinh, and Zzzz.[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-439)-- The only scripts found below U+0370 (the first code point of the Greek[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-440)-- and Coptic block) are Latn, Zyyy, Zinh, and Zzzz.[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-441)-- See the codepage in the [[[UTF-8]]](https://freemwiki.com/wiki/UTF-8 "UTF-8") article.[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-442)if not str:find "[\205-\244]" then[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-443)for codepoint in mw.ustring.gcodepoint(str) do[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-444)if lookup_script(codepoint) == "Latn" then[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-445)return true[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-446)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-447)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-448)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-449)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-450)local Latn = false[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-451)local i = 0;-- indexer for use in error messages[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-452)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-453)for codepoint in mw.ustring.gcodepoint(str) do[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-454)i = i + 1;-- bump the indexer[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-455)local script = lookup_script(codepoint)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-456)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-457)if script == "Latn" then[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-458)Latn = true[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-459)elseif not (script == "Zyyy" or script == "Zinh"[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-460)or script == "Zzzz") then[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-461)return false, i-- abandon as not Latn; identify the offending character's position[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-462)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-463)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-464)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-465)return Latn, (not Latn and i) or nil-- when false, return offending charactor's position as second return value; nil else[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-466)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-467)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-468)-- Checks that a string contains only characters belonging to right-to-left[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-469)-- scripts, or characters of ignorable scripts.[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-470)function p.is_rtl(str)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-471)require "libraryUtil".checkType("get_best_script", 1, str, "string")[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-472)str = mw.text.decode(str, true)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-473)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-474)-- Search for the leading bytes that introduce the UTF-8 encoding of the[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-475)-- code points U+0580-U+10FFFF. If they are not found, the string can only[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-476)-- have characters from a left-to-right script, because the first code point[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-477)-- in a right-to-left script is U+0591, in the Hebrew block.[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-478)if not str:find "[\214-\244]" then[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-479)return false[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-480)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-481)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-482)local result = false[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-483)local rtl = loader.scripts.rtl[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-484)for codepoint in mw.ustring.gcodepoint(str) do[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-485)local script = lookup_script(codepoint)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-486)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-487)if rtl[script] then[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-488)result = true[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-489)elseif not (script == "Zyyy" or script == "Zinh"[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-490)or script == "Zzzz") then[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-491)return false[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-492)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-493)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-494)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-495)return result[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-496)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-497)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-498)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-499)--[[--------------------------< I S _ R T L _ F R A M E >------------------------------------------------------[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-500)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-501)external entry from an {{#invoke:}} to determine if a string of text is rtl. Strips html and html-like tags so[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-502)that those tags don't corrupt the is-rtl-is-not-rtl determination; this added for the cases where the rtl text[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-503)has
tags.[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-504)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-505)]][](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-506)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-507)function p.is_rtl_frame (frame)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-508)local str = frame.args[1];-- get the string from the {{#invoke:}} frame[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-509)str = str:gsub ('%b<>', '');-- strip any html and html-like tags[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-510)return p.is_rtl (str);-- return if whatever remains rtl; false else[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-511)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-512)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-513)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-514)local function get_codepoint(args, arg)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-515)local codepoint_string = args[arg][](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-516)or errorf(2, "Parameter %s is required", tostring(arg))[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-517)local codepoint = tonumber(codepoint_string, 16)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-518)or errorf(2, "Parameter %s is not a code point in hexadecimal base",[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-519)tostring(arg))[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-520)if not (0 <= codepoint and codepoint <= 0x10FFFF) then[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-521)errorf(2, "code point in parameter %s out of range", tostring(arg))[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-522)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-523)return codepoint[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-524)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-525)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-526)local function get_func(args, arg, prefix)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-527)local suffix = args[arg][](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-528)or errorf(2, "Parameter %s is required", tostring(arg))[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-529)suffix = mw.text.trim(suffix)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-530)local func_name = prefix .. suffix[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-531)local func = p[func_name][](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-532)or errorf(2, "There is no function '%s'", func_name)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-533)return func[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-534)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-535)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-536)-- This function allows any of the "lookup" functions to be invoked. The first[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-537)-- parameter is the word after "lookup_"; the second parameter is the code point[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-538)-- in hexadecimal base.[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-539)function p.lookup(frame)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-540)local func = get_func(frame.args, 1, "lookup_")[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-541)local codepoint = get_codepoint(frame.args, 2)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-542)local result = func(codepoint)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-543)if func == p.lookup_name then[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-544)-- Prevent code point labels such as from being[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-545)-- interpreted as HTML tags.[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-546)result = result:gsub("<", "<")[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-547)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-548)return result[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-549)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-550)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-551)function p.is(frame)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-552)local func = get_func(frame.args, 1, "is_")[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-553)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-554)-- is_Latin and is_valid_pagename take strings.[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-555)if func == p.is_Latin or func == p.is_valid_pagename or func == p.is_rtl then[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-556)return (func(frame.args[2]))[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-557)else -- The rest take code points.[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-558)local codepoint = get_codepoint(frame.args, 2)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-559)return (func(codepoint)) -- Adjust to one result.[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-560)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-561)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-562)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-563)function p.lookup_kCantonese(codepoint)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-564)local data = loader[('Unihan/kCantonese/%02X'):format(floor(codepoint / 0x1000))][](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-565)if data then[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-566)return data[codepoint][](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-567)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-568)end[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-569)[](https://freemwiki.com/index.php?oldid=579706&title=Module%3AUnicode_data#L-570)return p Retrieved from "[https://freemwiki.com/index.php?title=Module:Unicode_data&oldid=579706](https://freemwiki.com/index.php?title=Module:Unicode_data&oldid=579706)" * This page was last edited on 21 October 2025, at 06:18. * Content is available under [Creative Commons Attribution-ShareAlike 4.0](https://creativecommons.org/licenses/by-sa/4.0/) unless otherwise noted. FreemWiki is operated by **FINGERPOWER DIGITAL TECHNOLOGY LLC** (Colorado, Entity ID 20221978727). * [Privacy Policy](https://freemwiki.com/wiki/Privacy_Policy) * [About](https://freemwiki.com/wiki/About) * [Terms of Service](https://freemwiki.com/wiki/Terms_of_Service) * [Mobile view](https://freemwiki.com/index.php?title=Module:Unicode_data&oldid=579706&mobileaction=toggle_view_mobile)