encoding/Data/Encoding/ISO88591.hs
Henning Guenther 0e4f3e9d2b Made DynEncoding an instance of Eq
darcs-hash:20080101224724-a4fee-4ff48f9729414a347da55cb95223429baf0587c1
2008-01-01 14:47:24 -08:00

27 lines
718 B
Haskell

{-# LANGUAGE CPP,TemplateHaskell,DeriveDataTypeable #-}
{- | 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.Char(ord,chr)
import Data.Word
import Control.Exception
import Data.Typeable
data ISO88591 = ISO88591 deriving (Eq,Show,Typeable)
enc :: Char -> Word8
enc c = if ord c < 256
then fromIntegral $ ord c
else throwDyn (HasNoRepresentation c)
instance Encoding ISO88591 where
encode _ = encodeSinglebyte enc
encodeLazy _ = encodeSinglebyteLazy enc
encodable _ c = ord c < 256
decode _ = decodeSinglebyte (chr.fromIntegral)