From 59a85267279be45069f5e80564bf77a0e34e145f Mon Sep 17 00:00:00 2001 From: Henning Guenther Date: Sat, 19 Jan 2008 15:27:05 -0800 Subject: [PATCH] Better detection of UTF16 endianess darcs-hash:20080119232705-a4fee-ff06e72d08068de9566b37cbc3e31f1e944162ea --- Data/Encoding/UTF16.hs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Data/Encoding/UTF16.hs b/Data/Encoding/UTF16.hs index 66e3630..d61c0f1 100644 --- a/Data/Encoding/UTF16.hs +++ b/Data/Encoding/UTF16.hs @@ -81,8 +81,8 @@ instance Encoding UTF16 where UTF16 -> Put2 0xFE 0xFF _ -> Done,str) encodable _ c = ord c <= 0x0010FFFF - decode _ str = case findByteOrder str of - Nothing -> decode' True 0 + decode bo str = case findByteOrder str of + Nothing -> decode' (bo/=UTF16LE) 0 Just big -> decode' big 2 where l = BS.length str @@ -97,8 +97,8 @@ instance Encoding UTF16 where s2 = index str (i+1) s3 = index str (i+2) s4 = index str (i+3) - decodeLazy _ str = case findByteOrderLazy str of - Nothing -> decode' True 0 + decodeLazy bo str = case findByteOrderLazy str of + Nothing -> decode' (bo/=UTF16LE) 0 Just big -> decode' big 2 where l = LBS.length str @@ -113,8 +113,8 @@ instance Encoding UTF16 where s2 = LBS.index str (i+1) s3 = LBS.index str (i+2) s4 = LBS.index str (i+3) - decodable _ str = case findByteOrder str of - Nothing -> check' True (length str) 0 + decodable bo str = case findByteOrder str of + Nothing -> check' (bo/=UTF16LE) (length str) 0 Just big -> check' big (length str) 2 where check' be m i