blob: 6c9dca14891ae7dfd9414be9eb621967a191b9d3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
import Control.Monad
import System.IO
import System.IO.Error
import GHC.IO.Encoding (utf8)
import GHC.IO.Handle (hSetEncoding)
testfiles = ["decodingerror001.in1", "decodingerror001.in2"]
main = mapM_ alltests testfiles
alltests file = mapM (test file) [NoBuffering,
LineBuffering,
BlockBuffering Nothing,
BlockBuffering (Just 9),
BlockBuffering (Just 23) ]
test file bufmode = do
h <- openFile file ReadMode
hSetEncoding h utf8
hSetBuffering h bufmode
e <- try $ forever $ hGetChar h >>= putChar
print (e :: Either IOError ())
|