Skip to content

Commit bdc6695

Browse files
committed
Format ExitCodeException stdout and stderr with UTF-8
Closes #86
1 parent b99e450 commit bdc6695

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

package.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ dependencies:
1919
- bytestring
2020
- process >=1.2
2121
- stm
22+
- text
2223
- transformers
2324
- unliftio-core
2425

src/System/Process/Typed/Internal.hs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ import Control.Concurrent.Async (async)
2323
import Control.Concurrent.STM (newEmptyTMVarIO, atomically, putTMVar, readTMVar, STM, tryPutTMVar, throwSTM)
2424
import System.Exit (ExitCode)
2525
import qualified Data.ByteString.Lazy as L
26-
import qualified Data.ByteString.Lazy.Char8 as L8
2726
import Data.String (IsString (fromString))
2827
import Control.Monad.IO.Unlift
28+
import qualified Data.Text.Encoding.Error as TEE
29+
import qualified Data.Text.Lazy as TL
30+
import qualified Data.Text.Lazy.Encoding as TLE
2931

3032
#if MIN_VERSION_process(1, 4, 0) && !WINDOWS
3133
import System.Posix.Types (GroupID, UserID)
@@ -626,7 +628,7 @@ instance Show ExitCodeException where
626628
else "Standard error:\n\n" ++ unpack (eceStderr ece)
627629
]
628630
where
629-
unpack = L8.unpack
631+
unpack = TL.unpack . TLE.decodeUtf8With TEE.lenientDecode
630632

631633
-- | Wrapper for when an exception is thrown when reading from a child
632634
-- process, used by 'byteStringOutput'.

0 commit comments

Comments
 (0)