encoding/Data/Encoding/ISO88591.hs
Henning Guenther eeee054f1e Rewrite to support more sources and changing the encoding dynamically
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
2009-02-21 12:31:00 -08:00

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)