diff options
author | Joey Hess <joey@kitenet.net> | 2014-02-03 10:08:28 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-02-03 10:08:28 -0400 |
commit | 6295ec998fb65607fb8c1d88035b41fa0cb3b0d6 (patch) | |
tree | d0beeb09a7e2488abad86ccad93afee524c8baa7 /Utility | |
parent | 10ad429a1e7028e464c02b91088d0952a3bfa5f8 (diff) |
factor out utility function
Diffstat (limited to 'Utility')
-rw-r--r-- | Utility/Misc.hs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Utility/Misc.hs b/Utility/Misc.hs index b93b772a9..20007adad 100644 --- a/Utility/Misc.hs +++ b/Utility/Misc.hs @@ -40,6 +40,13 @@ readFileStrictAnyEncoding f = withFile f ReadMode $ \h -> do fileEncoding h hClose h `after` hGetContentsStrict h +{- Writes a file, using the FileSystemEncoding so it will never crash + - on a badly encoded content string. -} +writeFileAnyEncoding :: FilePath -> String -> IO () +writeFileAnyEncoding f content = withFile f WriteMode $ \h -> do + fileEncoding h + hPutStr h content + {- Like break, but the item matching the condition is not included - in the second result list. - |