@@ -3010,11 +3010,11 @@ replacementChar :: Char
3010replacementChar = '\xFFFD'
3010replacementChar = '\xFFFD'
3012type CodePoint = Word32
3012type CodePoint = Word32
3013−type DecoderState = Word32
3013+type DecoderState = Word8
3015-- See http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ for details.
3015-- See http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ for details.
3017−utf8d :: A.Array Word32
3017+utf8d :: A.Array Word8
3018utf8d = A.fromList [
3018utf8d = A.fromList [
3019 -- The first part of the table maps bytes to character classes that
3019 -- The first part of the table maps bytes to character classes that
3020 -- to reduce the size of the transition table and create bitmasks.
3020 -- to reduce the size of the transition table and create bitmasks.
@@ -3037,14 +3037,15 @@ utf8d = A.fromList [
3039{-# INLINE decode #-}
3039{-# INLINE decode #-}
3040−decode :: DecoderState -> CodePoint -> Word32 -> Tuple' DecoderState CodePoint
3040+decode :: DecoderState -> CodePoint -> Word8 -> Tuple' DecoderState CodePoint
3041decode state codep byte =
3041decode state codep byte =
3042− let t = utf8d `A.unsafeIndex` (fromIntegral byte)
3042+ let t = utf8d `A.unsafeIndex` fromIntegral byte
3043 codep' =
3043 codep' =
3044 if state /= 0
3044 if state /= 0
3045− then (byte .&. 0x3f) .|. (codep `shiftL` 6)
3045+ then (fromIntegral byte .&. 0x3f) .|. (codep `shiftL` 6)
3046− else (0xff `shiftR` (fromIntegral t)) .&. byte
3046+ else (0xff `shiftR` (fromIntegral t)) .&. fromIntegral byte
3047− state' = utf8d `A.unsafeIndex` (fromIntegral $ 256 + state + t)
3047+ state' = utf8d `A.unsafeIndex`
3048+ (256 + fromIntegral state + fromIntegral t)
3048 in (Tuple' state' codep')
3049 in (Tuple' state' codep')
3050data FreshPoint s
3051data FreshPoint s
@@ -3075,7 +3076,7 @@ decodeUtf8With cfm (Stream step state) = Stream step' (FreshPoint 0 0 state)
3075 case r of
3076 case r of
3076 Yield x s ->
3077 Yield x s ->
3077 let (Tuple' sv cp) =
3078 let (Tuple' sv cp) =
3078− decode statePtr codepointPtr (fromIntegral x)
3079+ decode statePtr codepointPtr x
3079 in case sv of
3080 in case sv of
@@ -3161,7 +3162,7 @@ decodeUtf8ArraysWith cfm (Stream step state) =
3161 r <- peek p
3162 r <- peek p
3162 touchForeignPtr startf
3163 touchForeignPtr startf
3163 return r
3164 return r
3164− let (Tuple' sv cp) = decode statePtr codepointPtr (fromIntegral x)
3165+ let (Tuple' sv cp) = decode statePtr codepointPtr x
3165 return $
3166 return $
3166 case sv of
3167 case sv of