Ignore-this: 3b03abece3edb25c656f84db9cef7734 darcs-hash:20121017171258-76d51-76a4e9057c0a4c3c1370485f3dc072c18caafddf
22 lines
591 B
Haskell
22 lines
591 B
Haskell
{-# LANGUAGE DeriveDataTypeable #-}
|
|
module Data.Encoding.ASCII where
|
|
|
|
import Control.Throws
|
|
import Data.Char
|
|
import Data.Encoding.Base
|
|
import Data.Encoding.ByteSource
|
|
import Data.Encoding.ByteSink
|
|
import Data.Encoding.Exception
|
|
import Data.Typeable
|
|
|
|
data ASCII = ASCII deriving (Show,Eq,Typeable)
|
|
|
|
instance Encoding ASCII where
|
|
decodeChar _ = do
|
|
w <- fetchWord8
|
|
return $ chr $ fromIntegral w
|
|
encodeChar enc c
|
|
| encodeable enc c = pushWord8 . fromIntegral . ord $ c
|
|
| otherwise = throwException . HasNoRepresentation $ c
|
|
encodeable _ c = c < '\128'
|