git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Strict handling of UTF8 files (fixes fd issue) (#2338)

* Strict handling of UTF8 files (fixes fd issue) * Update CONTRIBUTORS.md

commit2cad87835dbf8c9dba2ad810b32a97579ec52af6 authorChris Done <chrisdone@gmail.com> dateFri 30 Sep 2016, 00:45 (10 years ago) parentac9ad9a
2 files changed+5−15
CONTRIBUTORS.md+1 src/System/IO/UTF8.hs+4−15
CONTRIBUTORS.md+1
@@ -18,6 +18,7 @@ This file lists the contributors to the PureScript compiler project, and the ter
1818- [@bsermons](https://github.com/bsermons) (Brian Sermons) My existing contributions and all future contributions until further notice are Copyright Brian Sermons, and are licensed to the owners and users of the PureScript compiler project under the terms of the [MIT license](http://opensource.org/licenses/MIT).
1919- [@cdepillabout](https://github.com/cdepillabout) (Dennis Gosnell) My existing contributions and all future contributions until further notice are Copyright Dennis Gosnell, and are licensed to the owners and users of the PureScript compiler project under the terms of the [MIT license](http://opensource.org/licenses/MIT).
2020- [@charleso](https://github.com/charleso) (Charles O'Farrell) My existing contributions to the PureScript compiler and all future contributions to the PureScript compiler until further notice, are Copyright Charles O'Farrell, and are licensed to the owners and users of the PureScript compiler project under the terms of the [MIT license](http://opensource.org/licenses/MIT).
21+- [@chrisdone](https://github.com/chrisdone) (Chris Done) - My existing contributions and all future contributions until further notice are Copyright Chris Done, and are licensed to the owners and users of the PureScript compiler project under the terms of the MIT license.
2122- [@chrissmoak](https://github.com/chrissmoak) (Chris Smoak) My existing contributions to the PureScript compiler and all future contributions to the PureScript compiler until further notice, are Copyright Chris Smoak, and are licensed to the owners and users of the PureScript compiler project under the terms of the [MIT license](http://opensource.org/licenses/MIT).
2223- [@codedmart](https://github.com/codedmart) (Brandon Martin) My existing contributions and all future contributions until further notice are Copyright Brandon Martin, and are licensed to the owners and users of the PureScript compiler project under the terms of the [MIT license](http://opensource.org/licenses/MIT).
2324- [@davidchambers](https://github.com/davidchambers) (David Chambers) My existing contributions and all future contributions until further notice are Copyright David Chambers, and are licensed to the owners and users of the PureScript compiler project under the terms of the [MIT license](http://opensource.org/licenses/MIT).
src/System/IO/UTF8.hs+4−15
@@ -2,24 +2,13 @@ module System.IO.UTF8 where
22
33import Prelude.Compat
44
5−import System.IO ( IOMode(..)
6− , hGetContents
7− , hSetEncoding
8− , hClose
9− , hPutStr
10− , openFile
11− , utf8
12− )
5+import qualified Data.ByteString as BS
6+import qualified Data.ByteString.UTF8 as UTF8
137
148readUTF8File :: FilePath -> IO String
159readUTF8File inFile = do
16− h <- openFile inFile ReadMode
17− hSetEncoding h utf8
18− hGetContents h
10+ fmap UTF8.toString (BS.readFile inFile)
1911
2012writeUTF8File :: FilePath -> String -> IO ()
2113writeUTF8File inFile text = do
22− h <- openFile inFile WriteMode
23− hSetEncoding h utf8
24− hPutStr h text
25− hClose h
14+ BS.writeFile inFile (UTF8.fromString text)