set locale encoding after fdTohandle
fdToHandle does not set the usual system locale encoding, so when the Handle is used for any String IO, it needs to be done manually for correctness. I don't know if this fixes any bugs. It might eg, fix a bug with multicast receive of a file. Sponsored-by: Leon Schuermann
This commit is contained in:
parent
1e847fd1af
commit
06a813ad44
4 changed files with 22 additions and 5 deletions
|
@ -23,6 +23,7 @@ import Control.Monad
|
|||
#ifndef mingw32_HOST_OS
|
||||
import Control.Exception
|
||||
import qualified System.Posix.IO
|
||||
import GHC.IO.Encoding (getLocaleEncoding)
|
||||
#else
|
||||
import Control.Applicative
|
||||
#endif
|
||||
|
@ -51,6 +52,9 @@ processTranscript'' cp input = do
|
|||
System.Posix.IO.setFdOption writef System.Posix.IO.CloseOnExec True
|
||||
readh <- System.Posix.IO.fdToHandle readf
|
||||
writeh <- System.Posix.IO.fdToHandle writef
|
||||
enc <- getLocaleEncoding
|
||||
hSetEncoding readh enc
|
||||
hSetEncoding writeh enc
|
||||
return (readh, writeh)
|
||||
let cleanup (readh, writeh) = do
|
||||
hClose readh
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue