summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/l-unicode.lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2018-01-12 08:12:50 +0100
committerContext Git Mirror Bot <phg42.2a@gmail.com>2018-01-12 08:12:50 +0100
commitd0edf3e90e8922d9c672f24ecdc5d44fe2716f31 (patch)
tree5b618b87aa5078a8c744c94bbf058d69cd7111b2 /tex/context/base/mkiv/l-unicode.lua
parent409a95f63883bd3b91699d39645e39a8a761457c (diff)
downloadcontext-d0edf3e90e8922d9c672f24ecdc5d44fe2716f31.tar.gz
2018-01-08 23:11:00
Diffstat (limited to 'tex/context/base/mkiv/l-unicode.lua')
-rw-r--r--tex/context/base/mkiv/l-unicode.lua26
1 files changed, 26 insertions, 0 deletions
diff --git a/tex/context/base/mkiv/l-unicode.lua b/tex/context/base/mkiv/l-unicode.lua
index a470fe1ff..60a8cc006 100644
--- a/tex/context/base/mkiv/l-unicode.lua
+++ b/tex/context/base/mkiv/l-unicode.lua
@@ -18,6 +18,9 @@ if not modules then modules = { } end modules ['l-unicode'] = {
-- todo: utf.sub replacement (used in syst-aux)
-- we put these in the utf namespace:
+-- used : byte char gmatch len lower sub upper
+-- not used : dump find format gfind gsub match rep reverse
+
utf = utf or (unicode and unicode.utf8) or { }
utf.characters = utf.characters or string.utfcharacters
@@ -1310,3 +1313,26 @@ function unicode.toutf32string(n)
char(extract(n,24,8))
end
end
+
+-- goodie:
+
+local len = utf.len
+local rep = rep
+
+function string.utfpadd(s,n)
+ if n and n ~= 0 then
+ local l = len(s)
+ if n > 0 then
+ local d = n - l
+ if d > 0 then
+ return rep(c or " ",d) .. s
+ end
+ else
+ local d = - n - l
+ if d > 0 then
+ return s .. rep(c or " ",d)
+ end
+ end
+ end
+ return s
+end