From 5f2ef13d20837eb9c0fe84a378e70c5066e6d021 Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Fri, 21 May 2010 06:22:29 +0300 Subject: Sync with ConTeXt beta (beta 2010.05.20) Needed to sync luaotfload. --- lualibs-unicode.lua | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'lualibs-unicode.lua') 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) -- cgit v1.2.3