encoding/Data/Encoding/ISO88591.hs
Henning Guenther cb81698b7e Derived all encodings from Show
This way, we can declare DynEncoding an instance of Show

darcs-hash:20070827020833-a4fee-a84635bf911573022b780c17b2085ff814302b3e
2007-08-26 19:08:33 -07:00

26 lines
634 B
Haskell

{- | Implements ISO\/IEC 8859-1 alias latin-1 encoding. See
<http://en.wikipedia.org/wiki/ISO/IEC_8859-1> for further informations.
-}
module Data.Encoding.ISO88591
(ISO88591(..)
) where
import Data.Encoding.Base
import Data.ByteString.Base(c2w,w2c)
import Data.Char(ord,chr)
import Data.Word
import Control.Exception
data ISO88591 = ISO88591 deriving Show
enc :: Char -> Word8
enc c = if ord c < 256
then c2w c
else throwDyn (HasNoRepresentation c)
instance Encoding ISO88591 where
encode _ = encodeSinglebyte enc
encodeLazy _ = encodeSinglebyteLazy enc
encodable _ c = ord c < 256
decode _ = decodeSinglebyte w2c