diff options
Diffstat (limited to 'tex/context/base/mkiv/l-unicode.lua')
-rw-r--r-- | tex/context/base/mkiv/l-unicode.lua | 26 |
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 |