decodingerror002.hs 526 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
import Control.Monad
import System.IO
import System.IO.Error
import GHC.IO.Handle (hSetEncoding)

main = alltests "decodingerror002.in"

alltests file = mapM (test file)  ["UTF8",
                                   "UTF8//IGNORE",
                                   "UTF8//TRANSLIT",
                                   "UTF8//ROUNDTRIP"]

test file enc_name = do
  h <- openFile file ReadMode
  enc <- mkTextEncoding enc_name
  hSetEncoding h enc
  e <- try $ forever $ hGetChar h >>= putChar
  print (e :: Either IOError ())