summaryrefslogtreecommitdiff
path: root/lualibs-unicode.lua
diff options
context:
space:
mode:
authorKhaled Hosny <khaledhosny@eglug.org>2010-05-21 06:22:29 +0300
committerKhaled Hosny <khaledhosny@eglug.org>2010-05-21 06:22:29 +0300
commit5f2ef13d20837eb9c0fe84a378e70c5066e6d021 (patch)
tree8da8eb76198b5015119d88aeb0480dedefa27e1d /lualibs-unicode.lua
parent2ede45796e70760267e4928dfff04d3546a8f159 (diff)
downloadlualibs-5f2ef13d20837eb9c0fe84a378e70c5066e6d021.tar.gz
Sync with ConTeXt beta (beta 2010.05.20)
Needed to sync luaotfload.
Diffstat (limited to 'lualibs-unicode.lua')
-rw-r--r--lualibs-unicode.lua12
1 files changed, 9 insertions, 3 deletions
diff --git a/lualibs-unicode.lua b/lualibs-unicode.lua
index 290234d..0c5a601 100644
--- a/lualibs-unicode.lua
+++ b/lualibs-unicode.lua
@@ -48,14 +48,20 @@ unicode.utfname = {
[4] = 'utf-32-be'
}
-function unicode.utftype(f) -- \000 fails !
+-- \000 fails in <= 5.0 but is valid in >=5.1 where %z is depricated
+
+function unicode.utftype(f)
local str = f:read(4)
if not str then
f:seek('set')
return 0
- elseif find(str,"^%z%z\254\255") then
+ -- elseif find(str,"^%z%z\254\255") then -- depricated
+ -- elseif find(str,"^\000\000\254\255") then -- not permitted and bugged
+ elseif find(str,"\000\000\254\255",1,true) then -- seems to work okay (TH)
return 4
- elseif find(str,"^\255\254%z%z") then
+ -- elseif find(str,"^\255\254%z%z") then -- depricated
+ -- elseif find(str,"^\255\254\000\000") then -- not permitted and bugged
+ elseif find(str,"\255\254\000\000",1,true) then -- seems to work okay (TH)
return 3
elseif find(str,"^\254\255") then
f:seek('set',2)