diff options
author | Hans Hagen <pragma@wxs.nl> | 2008-03-24 23:24:00 +0100 |
---|---|---|
committer | Hans Hagen <pragma@wxs.nl> | 2008-03-24 23:24:00 +0100 |
commit | 55bcf0e607bb8af553581e74293687ed635bf877 (patch) | |
tree | 328adc5c0c28d46fd49369999d0b160c3d7582f8 /tex/context/base/char-utf.lua | |
parent | 3bcf8de3c62348cb5526ddb37b3f4ea0f3d1df4f (diff) | |
download | context-55bcf0e607bb8af553581e74293687ed635bf877.tar.gz |
stable 2008.03.24 23:24
Diffstat (limited to 'tex/context/base/char-utf.lua')
-rw-r--r-- | tex/context/base/char-utf.lua | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/tex/context/base/char-utf.lua b/tex/context/base/char-utf.lua index fcb8804dd..5e5d575c5 100644 --- a/tex/context/base/char-utf.lua +++ b/tex/context/base/char-utf.lua @@ -138,34 +138,42 @@ to their right glyph there.</p> 0x100000.</p> --ldx]]-- -characters.filters.utf.private = { } -characters.filters.utf.private.high = { } -characters.filters.utf.private.low = { } +characters.filters.utf.private = { + high = { }, + low = { }, + escapes = { }, +} do + local low = characters.filters.utf.private.low + local high = characters.filters.utf.private.high + local escapes = characters.filters.utf.private.escapes + local special = "~#$%^&_{}\\" + local ub, uc, ug = utf.byte, utf.char, utf.gsub - local cfup = characters.filters.utf.private function characters.filters.utf.private.set(ch) - local cb = ub(ch) + local cb + if type(ch) == "number" then + cb, ch = ch, uc(ch) + else + cb = ub(ch) + end if cb < 256 then - cfup.low[ch] = uc(0x0F0000 + cb) - cfup.high[uc(0x0F0000 + cb)] = ch + low [ch] = uc(0x0F0000 + cb) + high [uc(0x0F0000 + cb)] = ch + escapes[ch] = "\\" .. ch end end - function characters.filters.utf.private.replace(str) - ug("(.)", cfup.low) - end + function characters.filters.utf.private.replace(str) return ug(str,"(.)", low ) end + function characters.filters.utf.private.revert(str) return ug(str,"(.)", high ) end + function characters.filters.utf.private.escape(str) return ug(str,"(.)", escapes) end - function characters.filters.utf.private.revert(str) - ug("(.)", cfup.high) - end + local set = characters.filters.utf.private.set - for _, ch in ipairs({ '~', '#', '$', '%', '^', '&', '_', '{', '}' }) do - cfup.set(ch) - end + for ch in special:gmatch(".") do set(ch) end end |