Module:Unicode data

Definition from Wiktionary, the free dictionary
Jump to: navigation, search
The following documentation is located at Module:Unicode data/documentation. [edit]

This module is used for accessing the Unicode character database, derived from files found in http://www.unicode.org/Public/UNIDATA/ .

Currently it exports two methods: lookup_name and template_lookup_name. Both, given a Unicode code point number, return the code point's name. The latter is suited for invocation through templates, while the former is intended to be used directly in Lua code.

Subpage index[edit]

Unicode data /aliases /combining
/control /documentation /names/000
/names/001 /names/002 /names/003
/names/004 /names/00A /names/00D
/names/00F /names/010 /names/011
/names/012 /names/013 /names/016
/names/01B /names/01D /names/01E
/names/01F /names/0E0 /yue-jyutping/003
/yue-jyutping/004 /yue-jyutping/005 /yue-jyutping/006
/yue-jyutping/007 /yue-jyutping/008 /yue-jyutping/009
/yue-jyutping/00F /yue-jyutping/020 /yue-jyutping/021
/yue-jyutping/022 /yue-jyutping/023 /yue-jyutping/024
/yue-jyutping/025 /yue-jyutping/026 /yue-jyutping/027
/yue-jyutping/028 /yue-jyutping/029 /yue-jyutping/02A
/yue-jyutping/02B /yue-jyutping/02F /yue-jyutping/reverse

Copyright[edit]

The Unicode database is released by Unicode Inc. under the following terms:

Copyright © 1991-2013 Unicode, Inc. All rights reserved. Distributed under the Terms of Use in http://www.unicode.org/copyright.html.

Permission is hereby granted, free of charge, to any person obtaining a copy of the Unicode data files and any associated documentation (the "Data Files") or Unicode software and any associated documentation (the "Software") to deal in the Data Files or Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, and/or sell copies of the Data Files or Software, and to permit persons to whom the Data Files or Software are furnished to do so, provided that (a) the above copyright notice(s) and this permission notice appear with all copies of the Data Files or Software, (b) both the above copyright notice(s) and this permission notice appear in associated documentation, and (c) there is clear notice in each modified Data File or in the Software as well as in the documentation associated with the Data File(s) or Software that the data or software has been modified.

THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA FILES OR SOFTWARE.

Except as contained in this notice, the name of a copyright holder shall not be used in advertising or otherwise to promote the sale, use or other dealings in these Data Files or Software without prior written authorization of the copyright holder.


local export = {}
 
-- http://www.unicode.org/Public/UNIDATA/Jamo.txt
local hangul_leads = {
	[0] = "G", "GG", "N", "D", "DD", "R", "M", "B", "BB", "S", "SS",
	"", "J", "JJ", "C", "K", "T", "P", "H"
}
 
local hangul_vowels = {
	[0] = "A", "AE", "YA", "YAE", "EO", "E", "YEO", "YE", "O", "WA",
	"WAE", "OE", "YO", "U", "WEO", "WE", "WI", "YU", "EU", "YI",
	"I"
}
 
local hangul_trails = {
	[0] = "", "G", "GG", "GS", "N", "NJ", "NH", "D", "L", "LG", "LM", "LB",
	"LS", "LT", "LP", "LH", "M", "B", "BS", "S", "SS", "NG", "J", "C", "K",
	"T", "P", "H"
}
 
local name_hooks = {
	[{     0x00,     0x1f }] = "<control-%04X>", -- C0 control characters
	[{     0x80,     0x9f }] = "<control-%04X>", -- C1 control characters
	[{   0x3400,   0x4db5 }] = "CJK UNIFIED IDEOGRAPH-%04X", -- CJK Ideograph Extension A
	[{   0x4e00,   0x9fcc }] = "CJK UNIFIED IDEOGRAPH-%04X", -- CJK Ideograph
	[{   0xac00,   0xd7a3 }] = function (codepoint)
		local m_hangul = require('Module:ko-hangul')
		local li, vi, ti = m_hangul.syllableIndex2JamoIndices(
			codepoint - 0xac00
		)
 
		return ("HANGUL SYLLABLE %s%s%s"):format(
			hangul_leads[li], -- I hate one-based indexing
			hangul_vowels[vi],
			hangul_trails[ti]  -- never mind, I can live with it
		)
	end,
	[{   0xd800,   0xdb7f }] = "<surrogate-%04X>", -- Non Private Use High Surrogate
	[{   0xdb80,   0xdbff }] = "<surrogate-%04X>", -- Private Use High Surrogate
	[{   0xdc00,   0xdfff }] = "<surrogate-%04X>", -- Low Surrogate
	[{   0xe000,   0xf8ff }] = "<private-use-%04X>", -- Private Use
	[{  0x20000,  0x2a6d6 }] = "CJK UNIFIED IDEOGRAPH-%04X", -- CJK Ideograph Extension B
	[{  0x2a700,  0x2b734 }] = "CJK UNIFIED IDEOGRAPH-%04X", -- CJK Ideograph Extension C
	[{  0x2a740,  0x2b81d }] = "CJK UNIFIED IDEOGRAPH-%04X", -- CJK Ideograph Extension D
	[{  0x2f800,  0x2fa1d }] = "CJK COMPATIBILITY IDEOGRAPH-%05X", -- CJK Compatibility Ideographs Supplement (Supplementary Ideographic Plane)
	[{  0xf0000,  0xffffd }] = "<private-use-%05X>", -- Plane 15 Private Use
	[{ 0x100000, 0x10fffd }] = "<private-use-%06X>"  -- Plane 16 Private Use
}
 
local noncharacters = {
	[  0xfdd0] = true, [  0xfdd1] = true,
	[  0xfdd2] = true, [  0xfdd3] = true,
	[  0xfdd4] = true, [  0xfdd5] = true,
	[  0xfdd6] = true, [  0xfdd7] = true,
	[  0xfdd8] = true, [  0xfdd9] = true,
	[  0xfdda] = true, [  0xfddb] = true,
	[  0xfddc] = true, [  0xfddd] = true,
	[  0xfdde] = true, [  0xfddf] = true,
	[  0xfde0] = true, [  0xfde1] = true,
	[  0xfde2] = true, [  0xfde3] = true,
	[  0xfde4] = true, [  0xfde5] = true,
	[  0xfde6] = true, [  0xfde7] = true,
	[  0xfde8] = true, [  0xfde9] = true,
	[  0xfdea] = true, [  0xfdeb] = true,
	[  0xfdec] = true, [  0xfded] = true,
	[  0xfdee] = true, [  0xfdef] = true,
 
	[  0xfffe] = true, [  0xffff] = true,
	[ 0x1fffe] = true, [ 0x1ffff] = true,
	[ 0x2fffe] = true, [ 0x2ffff] = true,
	[ 0x3fffe] = true, [ 0x3ffff] = true,
	[ 0x4fffe] = true, [ 0x4ffff] = true,
	[ 0x5fffe] = true, [ 0x5ffff] = true,
	[ 0x6fffe] = true, [ 0x6ffff] = true,
	[ 0x7fffe] = true, [ 0x7ffff] = true,
	[ 0x8fffe] = true, [ 0x8ffff] = true,
	[ 0x9fffe] = true, [ 0x9ffff] = true,
	[ 0xafffe] = true, [ 0xaffff] = true,
	[ 0xbfffe] = true, [ 0xbffff] = true,
	[ 0xcfffe] = true, [ 0xcffff] = true,
	[ 0xdfffe] = true, [ 0xdffff] = true,
	[ 0xefffe] = true, [ 0xeffff] = true,
	[ 0xffffe] = true, [ 0xfffff] = true,
	[0x10fffe] = true, [0x10ffff] = true
}
 
function export.lookup_name(codepoint)
	if noncharacters[codepoint] then
		return ("<noncharacter-%.4X>"):format(codepoint)
	end
 
	for key, hook in pairs(name_hooks) do
		if (codepoint >= key[1]) and (codepoint <= key[2]) then
			if type(hook) == "string" then
				return hook:format(codepoint)
			else
				return hook(codepoint)
			end
		end
	end
 
	local success, data = pcall(mw.loadData,
		('Module:Unicode data/names/%03X'):format(
			math.floor(codepoint / 0x1000)
		)
	)
 
	if success then
		return data[codepoint] or ("<U-%06X>"):format(codepoint)
	else
		return ("<U-%06X>"):format(codepoint)
	end
end
 
function export.template_lookup_name(frame)
	local codepoint = tonumber(frame.args[1] or frame:getParent().args[1])
	local name = export.lookup_name(codepoint)
	return name:gsub("<", "&lt;")
end
 
local planes = {
	[ 0] = "Basic Multilingual Plane";
	[ 1] = "Supplementary Multilingual Plane";
	[ 2] = "Supplementary Ideographic Plane";
	[13] = "Supplementary Special-purpose Plane";
	[14] = "Supplement­ary Private Use Area-A";
	[15] = "Supplement­ary Private Use Area-B";
}
 
-- http://www.unicode.org/Public/UNIDATA/Blocks.txt
local blocks = {
	["Basic Latin"                                       ] = {   0x0000,   0x007f }, 
	["Latin-1 Supplement"                                ] = {   0x0080,   0x00ff }, 
	["Latin Extended-A"                                  ] = {   0x0100,   0x017f }, 
	["Latin Extended-B"                                  ] = {   0x0180,   0x024f }, 
	["IPA Extensions"                                    ] = {   0x0250,   0x02af }, 
	["Spacing Modifier Letters"                          ] = {   0x02b0,   0x02ff }, 
	["Combining Diacritical Marks"                       ] = {   0x0300,   0x036f }, 
	["Greek and Coptic"                                  ] = {   0x0370,   0x03ff }, 
	["Cyrillic"                                          ] = {   0x0400,   0x04ff }, 
	["Cyrillic Supplement"                               ] = {   0x0500,   0x052f }, 
	["Armenian"                                          ] = {   0x0530,   0x058f }, 
	["Hebrew"                                            ] = {   0x0590,   0x05ff }, 
	["Arabic"                                            ] = {   0x0600,   0x06ff }, 
	["Syriac"                                            ] = {   0x0700,   0x074f }, 
	["Arabic Supplement"                                 ] = {   0x0750,   0x077f }, 
	["Thaana"                                            ] = {   0x0780,   0x07bf }, 
	["NKo"                                               ] = {   0x07c0,   0x07ff }, 
	["Samaritan"                                         ] = {   0x0800,   0x083f }, 
	["Mandaic"                                           ] = {   0x0840,   0x085f }, 
	["Arabic Extended-A"                                 ] = {   0x08a0,   0x08ff }, 
	["Devanagari"                                        ] = {   0x0900,   0x097f }, 
	["Bengali"                                           ] = {   0x0980,   0x09ff }, 
	["Gurmukhi"                                          ] = {   0x0a00,   0x0a7f }, 
	["Gujarati"                                          ] = {   0x0a80,   0x0aff }, 
	["Oriya"                                             ] = {   0x0b00,   0x0b7f }, 
	["Tamil"                                             ] = {   0x0b80,   0x0bff }, 
	["Telugu"                                            ] = {   0x0c00,   0x0c7f }, 
	["Kannada"                                           ] = {   0x0c80,   0x0cff }, 
	["Malayalam"                                         ] = {   0x0d00,   0x0d7f }, 
	["Sinhala"                                           ] = {   0x0d80,   0x0dff }, 
	["Thai"                                              ] = {   0x0e00,   0x0e7f }, 
	["Lao"                                               ] = {   0x0e80,   0x0eff }, 
	["Tibetan"                                           ] = {   0x0f00,   0x0fff }, 
	["Myanmar"                                           ] = {   0x1000,   0x109f }, 
	["Georgian"                                          ] = {   0x10a0,   0x10ff }, 
	["Hangul Jamo"                                       ] = {   0x1100,   0x11ff }, 
	["Ethiopic"                                          ] = {   0x1200,   0x137f }, 
	["Ethiopic Supplement"                               ] = {   0x1380,   0x139f }, 
	["Cherokee"                                          ] = {   0x13a0,   0x13ff }, 
	["Unified Canadian Aboriginal Syllabics"             ] = {   0x1400,   0x167f }, 
	["Ogham"                                             ] = {   0x1680,   0x169f }, 
	["Runic"                                             ] = {   0x16a0,   0x16ff }, 
	["Tagalog"                                           ] = {   0x1700,   0x171f }, 
	["Hanunoo"                                           ] = {   0x1720,   0x173f }, 
	["Buhid"                                             ] = {   0x1740,   0x175f }, 
	["Tagbanwa"                                          ] = {   0x1760,   0x177f }, 
	["Khmer"                                             ] = {   0x1780,   0x17ff }, 
	["Mongolian"                                         ] = {   0x1800,   0x18af }, 
	["Unified Canadian Aboriginal Syllabics Extended"    ] = {   0x18b0,   0x18ff }, 
	["Limbu"                                             ] = {   0x1900,   0x194f }, 
	["Tai Le"                                            ] = {   0x1950,   0x197f }, 
	["New Tai Lue"                                       ] = {   0x1980,   0x19df }, 
	["Khmer Symbols"                                     ] = {   0x19e0,   0x19ff }, 
	["Buginese"                                          ] = {   0x1a00,   0x1a1f }, 
	["Tai Tham"                                          ] = {   0x1a20,   0x1aaf }, 
	["Balinese"                                          ] = {   0x1b00,   0x1b7f }, 
	["Sundanese"                                         ] = {   0x1b80,   0x1bbf }, 
	["Batak"                                             ] = {   0x1bc0,   0x1bff }, 
	["Lepcha"                                            ] = {   0x1c00,   0x1c4f }, 
	["Ol Chiki"                                          ] = {   0x1c50,   0x1c7f }, 
	["Sundanese Supplement"                              ] = {   0x1cc0,   0x1ccf }, 
	["Vedic Extensions"                                  ] = {   0x1cd0,   0x1cff }, 
	["Phonetic Extensions"                               ] = {   0x1d00,   0x1d7f }, 
	["Phonetic Extensions Supplement"                    ] = {   0x1d80,   0x1dbf }, 
	["Combining Diacritical Marks Supplement"            ] = {   0x1dc0,   0x1dff }, 
	["Latin Extended Additional"                         ] = {   0x1e00,   0x1eff }, 
	["Greek Extended"                                    ] = {   0x1f00,   0x1fff }, 
	["General Punctuation"                               ] = {   0x2000,   0x206f }, 
	["Superscripts and Subscripts"                       ] = {   0x2070,   0x209f }, 
	["Currency Symbols"                                  ] = {   0x20a0,   0x20cf }, 
	["Combining Diacritical Marks for Symbols"           ] = {   0x20d0,   0x20ff }, 
	["Letterlike Symbols"                                ] = {   0x2100,   0x214f }, 
	["Number Forms"                                      ] = {   0x2150,   0x218f }, 
	["Arrows"                                            ] = {   0x2190,   0x21ff }, 
	["Mathematical Operators"                            ] = {   0x2200,   0x22ff }, 
	["Miscellaneous Technical"                           ] = {   0x2300,   0x23ff }, 
	["Control Pictures"                                  ] = {   0x2400,   0x243f }, 
	["Optical Character Recognition"                     ] = {   0x2440,   0x245f }, 
	["Enclosed Alphanumerics"                            ] = {   0x2460,   0x24ff }, 
	["Box Drawing"                                       ] = {   0x2500,   0x257f }, 
	["Block Elements"                                    ] = {   0x2580,   0x259f }, 
	["Geometric Shapes"                                  ] = {   0x25a0,   0x25ff }, 
	["Miscellaneous Symbols"                             ] = {   0x2600,   0x26ff }, 
	["Dingbats"                                          ] = {   0x2700,   0x27bf }, 
	["Miscellaneous Mathematical Symbols-A"              ] = {   0x27c0,   0x27ef }, 
	["Supplemental Arrows-A"                             ] = {   0x27f0,   0x27ff }, 
	["Braille Patterns"                                  ] = {   0x2800,   0x28ff }, 
	["Supplemental Arrows-B"                             ] = {   0x2900,   0x297f }, 
	["Miscellaneous Mathematical Symbols-B"              ] = {   0x2980,   0x29ff }, 
	["Supplemental Mathematical Operators"               ] = {   0x2a00,   0x2aff }, 
	["Miscellaneous Symbols and Arrows"                  ] = {   0x2b00,   0x2bff }, 
	["Glagolitic"                                        ] = {   0x2c00,   0x2c5f }, 
	["Latin Extended-C"                                  ] = {   0x2c60,   0x2c7f }, 
	["Coptic"                                            ] = {   0x2c80,   0x2cff }, 
	["Georgian Supplement"                               ] = {   0x2d00,   0x2d2f }, 
	["Tifinagh"                                          ] = {   0x2d30,   0x2d7f }, 
	["Ethiopic Extended"                                 ] = {   0x2d80,   0x2ddf }, 
	["Cyrillic Extended-A"                               ] = {   0x2de0,   0x2dff }, 
	["Supplemental Punctuation"                          ] = {   0x2e00,   0x2e7f }, 
	["CJK Radicals Supplement"                           ] = {   0x2e80,   0x2eff }, 
	["Kangxi Radicals"                                   ] = {   0x2f00,   0x2fdf }, 
	["Ideographic Description Characters"                ] = {   0x2ff0,   0x2fff }, 
	["CJK Symbols and Punctuation"                       ] = {   0x3000,   0x303f }, 
	["Hiragana"                                          ] = {   0x3040,   0x309f }, 
	["Katakana"                                          ] = {   0x30a0,   0x30ff }, 
	["Bopomofo"                                          ] = {   0x3100,   0x312f }, 
	["Hangul Compatibility Jamo"                         ] = {   0x3130,   0x318f }, 
	["Kanbun"                                            ] = {   0x3190,   0x319f }, 
	["Bopomofo Extended"                                 ] = {   0x31a0,   0x31bf }, 
	["CJK Strokes"                                       ] = {   0x31c0,   0x31ef }, 
	["Katakana Phonetic Extensions"                      ] = {   0x31f0,   0x31ff }, 
	["Enclosed CJK Letters and Months"                   ] = {   0x3200,   0x32ff }, 
	["CJK Compatibility"                                 ] = {   0x3300,   0x33ff }, 
	["CJK Unified Ideographs Extension A"                ] = {   0x3400,   0x4dbf }, 
	["Yijing Hexagram Symbols"                           ] = {   0x4dc0,   0x4dff }, 
	["CJK Unified Ideographs"                            ] = {   0x4e00,   0x9fff }, 
	["Yi Syllables"                                      ] = {   0xa000,   0xa48f }, 
	["Yi Radicals"                                       ] = {   0xa490,   0xa4cf }, 
	["Lisu"                                              ] = {   0xa4d0,   0xa4ff }, 
	["Vai"                                               ] = {   0xa500,   0xa63f }, 
	["Cyrillic Extended-B"                               ] = {   0xa640,   0xa69f }, 
	["Bamum"                                             ] = {   0xa6a0,   0xa6ff }, 
	["Modifier Tone Letters"                             ] = {   0xa700,   0xa71f }, 
	["Latin Extended-D"                                  ] = {   0xa720,   0xa7ff }, 
	["Syloti Nagri"                                      ] = {   0xa800,   0xa82f }, 
	["Common Indic Number Forms"                         ] = {   0xa830,   0xa83f }, 
	["Phags-pa"                                          ] = {   0xa840,   0xa87f }, 
	["Saurashtra"                                        ] = {   0xa880,   0xa8df }, 
	["Devanagari Extended"                               ] = {   0xa8e0,   0xa8ff }, 
	["Kayah Li"                                          ] = {   0xa900,   0xa92f }, 
	["Rejang"                                            ] = {   0xa930,   0xa95f }, 
	["Hangul Jamo Extended-A"                            ] = {   0xa960,   0xa97f }, 
	["Javanese"                                          ] = {   0xa980,   0xa9df }, 
	["Cham"                                              ] = {   0xaa00,   0xaa5f }, 
	["Myanmar Extended-A"                                ] = {   0xaa60,   0xaa7f }, 
	["Tai Viet"                                          ] = {   0xaa80,   0xaadf }, 
	["Meetei Mayek Extensions"                           ] = {   0xaae0,   0xaaff }, 
	["Ethiopic Extended-A"                               ] = {   0xab00,   0xab2f }, 
	["Meetei Mayek"                                      ] = {   0xabc0,   0xabff }, 
	["Hangul Syllables"                                  ] = {   0xac00,   0xd7af }, 
	["Hangul Jamo Extended-B"                            ] = {   0xd7b0,   0xd7ff }, 
	["High Surrogates"                                   ] = {   0xd800,   0xdb7f }, 
	["High Private Use Surrogates"                       ] = {   0xdb80,   0xdbff }, 
	["Low Surrogates"                                    ] = {   0xdc00,   0xdfff }, 
	["Private Use Area"                                  ] = {   0xe000,   0xf8ff }, 
	["CJK Compatibility Ideographs"                      ] = {   0xf900,   0xfaff }, 
	["Alphabetic Presentation Forms"                     ] = {   0xfb00,   0xfb4f }, 
	["Arabic Presentation Forms-A"                       ] = {   0xfb50,   0xfdff }, 
	["Variation Selectors"                               ] = {   0xfe00,   0xfe0f }, 
	["Vertical Forms"                                    ] = {   0xfe10,   0xfe1f }, 
	["Combining Half Marks"                              ] = {   0xfe20,   0xfe2f }, 
	["CJK Compatibility Forms"                           ] = {   0xfe30,   0xfe4f }, 
	["Small Form Variants"                               ] = {   0xfe50,   0xfe6f }, 
	["Arabic Presentation Forms-B"                       ] = {   0xfe70,   0xfeff }, 
	["Halfwidth and Fullwidth Forms"                     ] = {   0xff00,   0xffef }, 
	["Specials"                                          ] = {   0xfff0,   0xffff }, 
	["Linear B Syllabary"                                ] = {  0x10000,  0x1007f }, 
	["Linear B Ideograms"                                ] = {  0x10080,  0x100ff }, 
	["Aegean Numbers"                                    ] = {  0x10100,  0x1013f }, 
	["Ancient Greek Numbers"                             ] = {  0x10140,  0x1018f }, 
	["Ancient Symbols"                                   ] = {  0x10190,  0x101cf }, 
	["Phaistos Disc"                                     ] = {  0x101d0,  0x101ff }, 
	["Lycian"                                            ] = {  0x10280,  0x1029f }, 
	["Carian"                                            ] = {  0x102a0,  0x102df }, 
	["Old Italic"                                        ] = {  0x10300,  0x1032f }, 
	["Gothic"                                            ] = {  0x10330,  0x1034f }, 
	["Ugaritic"                                          ] = {  0x10380,  0x1039f }, 
	["Old Persian"                                       ] = {  0x103a0,  0x103df }, 
	["Deseret"                                           ] = {  0x10400,  0x1044f }, 
	["Shavian"                                           ] = {  0x10450,  0x1047f }, 
	["Osmanya"                                           ] = {  0x10480,  0x104af }, 
	["Cypriot Syllabary"                                 ] = {  0x10800,  0x1083f }, 
	["Imperial Aramaic"                                  ] = {  0x10840,  0x1085f }, 
	["Phoenician"                                        ] = {  0x10900,  0x1091f }, 
	["Lydian"                                            ] = {  0x10920,  0x1093f }, 
	["Meroitic Hieroglyphs"                              ] = {  0x10980,  0x1099f }, 
	["Meroitic Cursive"                                  ] = {  0x109a0,  0x109ff }, 
	["Kharoshthi"                                        ] = {  0x10a00,  0x10a5f }, 
	["Old South Arabian"                                 ] = {  0x10a60,  0x10a7f }, 
	["Avestan"                                           ] = {  0x10b00,  0x10b3f }, 
	["Inscriptional Parthian"                            ] = {  0x10b40,  0x10b5f }, 
	["Inscriptional Pahlavi"                             ] = {  0x10b60,  0x10b7f }, 
	["Old Turkic"                                        ] = {  0x10c00,  0x10c4f }, 
	["Rumi Numeral Symbols"                              ] = {  0x10e60,  0x10e7f }, 
	["Brahmi"                                            ] = {  0x11000,  0x1107f }, 
	["Kaithi"                                            ] = {  0x11080,  0x110cf }, 
	["Sora Sompeng"                                      ] = {  0x110d0,  0x110ff }, 
	["Chakma"                                            ] = {  0x11100,  0x1114f }, 
	["Sharada"                                           ] = {  0x11180,  0x111df }, 
	["Takri"                                             ] = {  0x11680,  0x116cf }, 
	["Cuneiform"                                         ] = {  0x12000,  0x123ff }, 
	["Cuneiform Numbers and Punctuation"                 ] = {  0x12400,  0x1247f }, 
	["Egyptian Hieroglyphs"                              ] = {  0x13000,  0x1342f }, 
	["Bamum Supplement"                                  ] = {  0x16800,  0x16a3f }, 
	["Miao"                                              ] = {  0x16f00,  0x16f9f }, 
	["Kana Supplement"                                   ] = {  0x1b000,  0x1b0ff }, 
	["Byzantine Musical Symbols"                         ] = {  0x1d000,  0x1d0ff }, 
	["Musical Symbols"                                   ] = {  0x1d100,  0x1d1ff }, 
	["Ancient Greek Musical Notation"                    ] = {  0x1d200,  0x1d24f }, 
	["Tai Xuan Jing Symbols"                             ] = {  0x1d300,  0x1d35f }, 
	["Counting Rod Numerals"                             ] = {  0x1d360,  0x1d37f }, 
	["Mathematical Alphanumeric Symbols"                 ] = {  0x1d400,  0x1d7ff }, 
	["Arabic Mathematical Alphabetic Symbols"            ] = {  0x1ee00,  0x1eeff }, 
	["Mahjong Tiles"                                     ] = {  0x1f000,  0x1f02f }, 
	["Domino Tiles"                                      ] = {  0x1f030,  0x1f09f }, 
	["Playing Cards"                                     ] = {  0x1f0a0,  0x1f0ff }, 
	["Enclosed Alphanumeric Supplement"                  ] = {  0x1f100,  0x1f1ff }, 
	["Enclosed Ideographic Supplement"                   ] = {  0x1f200,  0x1f2ff }, 
	["Miscellaneous Symbols And Pictographs"             ] = {  0x1f300,  0x1f5ff }, 
	["Emoticons"                                         ] = {  0x1f600,  0x1f64f }, 
	["Transport And Map Symbols"                         ] = {  0x1f680,  0x1f6ff }, 
	["Alchemical Symbols"                                ] = {  0x1f700,  0x1f77f }, 
	["CJK Unified Ideographs Extension B"                ] = {  0x20000,  0x2a6df }, 
	["CJK Unified Ideographs Extension C"                ] = {  0x2a700,  0x2b73f }, 
	["CJK Unified Ideographs Extension D"                ] = {  0x2b740,  0x2b81f }, 
	["CJK Compatibility Ideographs Supplement"           ] = {  0x2f800,  0x2fa1f }, 
	["Tags"                                              ] = {  0xe0000,  0xe007f }, 
	["Variation Selectors Supplement"                    ] = {  0xe0100,  0xe01ef }, 
	["Supplementary Private Use Area-A"                  ] = {  0xf0000,  0xfffff }, 
	["Supplementary Private Use Area-B"                  ] = { 0x100000, 0x10ffff }, 
}
 
function export.enum_blocks()
	local list = {}
 
	for name, range in pairs(blocks) do
		table.insert(list, { name, range[1], range[2] })
	end
	table.sort(list, function (apple, orange)
		return apple[2] < orange[2]
	end)
 
	return function (list, i)
		local data = list[i + 1]
		if not data then
			return nil	
		end
		return i + 1, data[1], data[2], data[3]
	end, list, 0
end
 
function export.lookup_plane(codepoint)
	local i = math.floor(codepoint / 0x10000)
	return planes[i] or ("Plane %u"):format(i)
end
 
function export.lookup_block(codepoint)
	for name, range in pairs(blocks) do
		if (codepoint >= range[1]) and (codepoint <= range[2]) then
			return name
		end
	end
end
 
function export.get_block_range(name)
	local range = blocks[name]
	if range then
		return range[1], range[2]
	end
end
 
local quick_ctl_lookup = {}
 
-- return true if codepoint is assigned to a non-control, non-private
-- (non-combining?) character, and therefore can be used in running text
-- second return value indicates reason why a character is not "printable".
function export.is_printable(codepoint)
	local m_cc = mw.loadData('Module:Unicode data/control')
 
	if m_cc.single[codepoint] then
		return false, m_cc.single[codepoint]
	end
 
	for _, range in pairs(quick_ctl_lookup) do
		if (range[1] <= codepoint) and (codepoint <= range[2]) then
			return false, range[3]
		end
	end
 
	for i, range in ipairs(m_cc.ranges) do
		if (range[1] <= codepoint) and (codepoint <= range[2]) then
			table.insert(quick_ctl_lookup, range)
			return false, range[3]
		end
	end
 
	return true
end
 
function export.is_assigned(codepoint)
	local m_cc = mw.loadData('Module:Unicode data/control')
 
	if m_cc.single[codepoint] then
		return m_cc.single[codepoint] ~= "unassigned"
	end
 
	for _, range in pairs(quick_ctl_lookup) do
		if (range[1] <= codepoint) and (codepoint <= range[2]) then
			return range[3] ~= "unassigned"
		end
	end
 
	for i, range in ipairs(m_cc.ranges) do
		if (range[1] <= codepoint) and (codepoint <= range[2]) then
			table.insert(quick_ctl_lookup, range)
			return range[3] ~= "unassigned"
		end
	end
 
	return true
end
 
function export.is_combining(codepoint)
	local m_comb = mw.loadData('Module:Unicode data/combining')
 
	if m_comb.single[codepoint] then
		return m_comb.single[codepoint] ~= 0
	end
 
	for i, range in ipairs(m_comb.ranges) do
		if (range[1] <= codepoint) and (codepoint <= range[2]) then
			return range[3] ~= 0
		end
	end
 
	return false
end
 
function export.is_valid_pagename(pagename)
	for cp in mw.ustring.gcodepoint(pagename) do
		if false
		or (cp == 0x0023) -- #
		or (cp == 0x005b) -- [
		or (cp == 0x005d) -- ]
		or (cp == 0x007b) -- {
		or (cp == 0x007c) -- |
		or (cp == 0x007d) -- }
		or (cp == 0x180e) -- MONGOLIAN VOWEL SEPARATOR
		or ((cp >= 0x2000) and (cp <= 0x200a))
		or (cp == 0xfffd) -- REPLACEMENT CHARACTER
		then
			return false	
		end
 
		if not export.is_printable(cp) then
			return false	
		end
	end
 
	return true
end
 
return export