encoding/Data/Encoding/ISO88591.hs
Henning Guenther 5528bf1a55 Added encodeable function
darcs-hash:20090225040044-a4fee-67753f6d651b18d5bd3a28340ea8f5d7ea7eb90d
2009-02-24 20:00:44 -08:00

21 lines
612 B
Haskell

{-# LANGUAGE DeriveDataTypeable #-}
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)
import Data.Typeable
data ISO88591 = ISO88591 deriving (Show,Eq,Typeable)
instance Encoding ISO88591 where
encodeChar _ c
| c > '\255' = throwException (HasNoRepresentation c)
| otherwise = pushWord8 (fromIntegral $ ord c)
decodeChar _ = do
w <- fetchWord8
return (chr $ fromIntegral w)
encodeable _ c = c <= '\255'