Typo
[packages/base.git] / tests / IO / decodingerror002.hs
1 import Control.Monad
2 import System.IO
3 import System.IO.Error
4 import GHC.IO.Handle (hSetEncoding)
5
6 main = do
7 -- Explicitly set stdout encoding so that the UTF8//ROUNDTRIP
8 -- test is always able to write the surrogate byte out without error.
9 enc <- mkTextEncoding "UTF-8//ROUNDTRIP"
10 hSetEncoding stdout enc
11 alltests "decodingerror002.in"
12
13 alltests file = mapM (test file) ["UTF-8",
14 "UTF-8//IGNORE",
15 "UTF-8//TRANSLIT",
16 "UTF-8//ROUNDTRIP"]
17
18 test file enc_name = do
19 h <- openFile file ReadMode
20 enc <- mkTextEncoding enc_name
21 hSetEncoding h enc
22 e <- tryIOError $ forever $ hGetChar h >>= putChar
23 print (e :: Either IOError ())