diff options
author | Marius <mariausol@gmail.com> | 2011-05-13 12:40:12 +0300 |
---|---|---|
committer | Marius <mariausol@gmail.com> | 2011-05-13 12:40:12 +0300 |
commit | 4a00862b42dd8347bd782022a819fa9c3a32f9a2 (patch) | |
tree | 1360a3144185079a59795bd6503910988b6c9755 /tex/context/base/l-unicode.lua | |
parent | 749d7be28ed620f9017cb6a65735ac937d1b8a86 (diff) | |
download | context-4a00862b42dd8347bd782022a819fa9c3a32f9a2.tar.gz |
beta 2011.05.13 11:37
Diffstat (limited to 'tex/context/base/l-unicode.lua')
-rw-r--r-- | tex/context/base/l-unicode.lua | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/tex/context/base/l-unicode.lua b/tex/context/base/l-unicode.lua index b64969162..2fa50282f 100644 --- a/tex/context/base/l-unicode.lua +++ b/tex/context/base/l-unicode.lua @@ -51,8 +51,10 @@ local unicode = unicode utf = utf or unicode.utf8 -local concat, utfchar, utfgsub = table.concat, utf.char, utf.gsub +local concat = table.concat +local utfchar, utfbyte, utfgsub = utf.char, utf.byte, utf.gsub local char, byte, find, bytepairs, utfvalues, format = string.char, string.byte, string.find, string.bytepairs, string.utfvalues, string.format +local type = type local utfsplitlines = string.utfsplitlines @@ -367,6 +369,14 @@ function unicode.utfcodes(str) return concat(t,separator or " ") end +function unicode.ustring(s) + return format("U+%05X",type(s) == "number" and s or utfbyte(s)) +end + +function unicode.xstring(s) + return format("0x%05X",type(s) == "number" and s or utfbyte(s)) +end + --~ print(unicode.utfcodes(str)) local lpegmatch = lpeg.match @@ -398,4 +408,3 @@ end --~ end --~ end --~ print(os.clock()-t,collectgarbage("count")*1024-u) - |