Module:User:Suzukaze-c/unicode
Appearance
- This module sandbox lacks a documentation subpage. Please create it.
- Useful links: root page • root page’s subpages • links • transclusions • testcases • sandbox
local export = {}
function export.show(text, prefix, case, separator)
if type(text) == "table" then
local a = text.args
text = a[1] or nil
prefix = a[2] or nil
case = a[3] or nil
separator = a[4] or nil
end
if not text then text = "test string" end
if not prefix then prefix = "U+" end
if not case then case = "upper" end
if not separator then separator = " " end
local cp = {}
for char in mw.text.gsplit(text, "") do
char = mw.ustring.codepoint(char)
char = string.format('%.4X', char) -- see [[Module:character info]]
if case == "lower" then
char = string.lower(char)
end
table.insert(cp, prefix .. char)
end
return table.concat(cp, separator)
end
return export