Advertisement
Guest User

Untitled

a guest
Aug 17th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. import System.IO (IOMode(..), hGetContents, openFile, openBinaryFile, utf8)
  2.  
  3. main =
  4. do h <- openBinaryFile "test-file.md" ReadMode
  5. hGetContentContents h
  6. -- Binary read works fine out-of-box.
  7.  
  8. h' <- openFile "test-file.md" ReadMode
  9. hSetEncoding h' utf8
  10. hGetContentContents h'
  11. -- This works only if encoding is explicitly set, otherwise
  12. -- it gives "invalid byte sequence" error at run-time
  13.  
  14. export LANG=en_US.UTF8 cabal build
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement