summaryrefslogtreecommitdiff
path: root/Utility
diff options
context:
space:
mode:
Diffstat (limited to 'Utility')
-rw-r--r--Utility/Misc.hs8
1 files changed, 8 insertions, 0 deletions
diff --git a/Utility/Misc.hs b/Utility/Misc.hs
index 3ac5ca5c0..9c284c826 100644
--- a/Utility/Misc.hs
+++ b/Utility/Misc.hs
@@ -9,6 +9,14 @@ module Utility.Misc where
import System.IO
import Control.Monad
+import GHC.IO.Encoding
+
+{- Sets a Handle to use the filesystem encoding. This causes data
+ - written or read from it to be encoded/decoded the same
+ - as ghc 7.4 does to filenames et. This special encoding
+ - allows "arbitrary undecodable bytes to be round-tripped through it". -}
+fileEncoding :: Handle -> IO ()
+fileEncoding h = hSetEncoding h =<< getFileSystemEncoding
{- A version of hgetContents that is not lazy. Ensures file is
- all read before it gets closed. -}