summaryrefslogtreecommitdiff
path: root/tex/context/base/l-unicode.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/l-unicode.lua')
-rw-r--r--tex/context/base/l-unicode.lua12
1 files changed, 11 insertions, 1 deletions
diff --git a/tex/context/base/l-unicode.lua b/tex/context/base/l-unicode.lua
index 0c5a60142..dc78f7325 100644
--- a/tex/context/base/l-unicode.lua
+++ b/tex/context/base/l-unicode.lua
@@ -32,7 +32,7 @@ end
utf = utf or unicode.utf8
local concat, utfchar, utfgsub = table.concat, utf.char, utf.gsub
-local char, byte, find, bytepairs = string.char, string.byte, string.find, string.bytepairs
+local char, byte, find, bytepairs, utfvalues, format = string.char, string.byte, string.find, string.bytepairs, string.utfvalues, string.format
-- 0 EF BB BF UTF-8
-- 1 FF FE UTF-16-little-endian
@@ -197,3 +197,13 @@ function unicode.utf8_to_utf16(str,littleendian)
return char(254,255) .. utfgsub(str,".",big)
end
end
+
+function unicode.utfcodes(str)
+ local t = { }
+ for k,v in string.utfvalues(str) do
+ t[#t+1] = format("0x%04X",k)
+ end
+ return concat(t,separator or " ")
+end
+
+--~ print(unicode.utfcodes(str))