Now it's possible to change the character encoding while de-/encoding. Also, it's possible to use any data structure as a source or target of the de-/encoding process. darcs-hash:20090221203100-a4fee-6da31f2e37c30a3f5cd5f10af71984209488bb0b
18 lines
510 B
Haskell
18 lines
510 B
Haskell
module Data.Encoding.ISO88591 where
|
|
|
|
import Control.Throws
|
|
import Data.Encoding.Base
|
|
import Data.Encoding.Exception
|
|
import Data.Encoding.ByteSource
|
|
import Data.Encoding.ByteSink
|
|
import Data.Char (ord,chr)
|
|
|
|
data ISO88591 = ISO88591 deriving (Show)
|
|
|
|
instance Encoding ISO88591 where
|
|
encodeChar _ c
|
|
| c > '\255' = throwException (HasNoRepresentation c)
|
|
| otherwise = pushWord8 (fromIntegral $ ord c)
|
|
decodeChar _ = do
|
|
w <- fetchWord8
|
|
return (chr $ fromIntegral w) |