encoding/Data/Encoding/ISO88591.hs
Henning Guenther 971927c91f Made extensions explicit
darcs-hash:20071229003551-a4fee-f01193be732b8f3f5085232f922490cd5b48706a
2007-12-28 16:35:51 -08:00

26 lines
664 B
Haskell

{-# LANGUAGE CPP,TemplateHaskell #-}
{- | 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
data ISO88591 = ISO88591 deriving Show
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)