on master help sign in
Fix "Invalid byte" on file read

We were reading input from a binary file trying to decode it as Char leading to an invalid byte sequence error.

commitc436e3c6240cf2d0ecf1aa1bd53f274c2af61dac authorHarendra Kumar <harendra@composewell.com> dateSat 24 Oct 2020, 00:06 (6 years ago) parentb1a9af0
1 file changed+2−2
benchmark/Streamly/Benchmark/FileSystem/Handle/ReadWrite.hs+2−2
benchmark/Streamly/Benchmark/FileSystem/Handle/ReadWrite.hs+2−2
@@ -24,7 +24,7 @@ module Handle.ReadWrite
2424where
2525
2626import Control.Exception (SomeException)
27−import System.IO (Handle, hClose, hGetChar)
27+import System.IO (Handle, hClose, hPutChar)
2828import Prelude hiding (last, length)
2929
3030import qualified Streamly.Data.Fold as FL
@@ -407,7 +407,7 @@ readWriteBeforeAfterStream :: Handle -> Handle -> IO ()
407407readWriteBeforeAfterStream inh devNull =
408408 let readEx =
409409 IP.after (hClose inh)
410− $ IP.before (hGetChar inh) (S.unfold FH.read inh)
410+ $ IP.before (hPutChar devNull 'A') (S.unfold FH.read inh)
411411 in S.fold (FH.write devNull) readEx
412412
413413readWriteAfterStream :: Handle -> Handle -> IO ()