Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import System.IO (IOMode(..), hGetContents, openFile, openBinaryFile, utf8)
- main =
- do h <- openBinaryFile "test-file.md" ReadMode
- hGetContentContents h
- -- Binary read works fine out-of-box.
- h' <- openFile "test-file.md" ReadMode
- hSetEncoding h' utf8
- hGetContentContents h'
- -- This works only if encoding is explicitly set, otherwise
- -- it gives "invalid byte sequence" error at run-time
- export LANG=en_US.UTF8 cabal build
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement