Skip to content

Commit

Permalink
Also decode Dex code files as UTF-8 regardless of the ambient locale.
Browse files Browse the repository at this point in the history
  • Loading branch information
axch committed Dec 14, 2022
1 parent 22c49ff commit d30ad52
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/dex.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import System.Posix.Terminal (queryTerminal)
import System.Posix.IO (stdOutput)
import System.IO (openFile, IOMode (..))

import qualified Data.ByteString as BS
import Data.List
import Data.Functor
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Encoding as T
import qualified Data.Map.Strict as M

import PPrint (toJSONStr, printResult)
Expand Down Expand Up @@ -58,7 +58,7 @@ runMode evalMode opts = case evalMode of
ScriptMode fname fmt onErr -> do
env <- loadCache
(litProg, finalEnv) <- runTopperM opts env do
source <- liftIO $ T.readFile fname
source <- liftIO $ T.decodeUtf8 <$> BS.readFile fname
evalSourceText source (printIncrementalSource fmt) \result@(Result _ errs) -> do
printIncrementalResult fmt result
return case (onErr, errs) of (HaltOnErr, Failure _) -> False; _ -> True
Expand Down
9 changes: 5 additions & 4 deletions src/lib/Live/Eval.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ module Live.Eval (RFragment (..), SetVal(..), watchAndEvalFile) where
import Control.Concurrent (forkIO, killThread, readChan, threadDelay, ThreadId)
import Control.Monad.Reader
import Control.Monad.State.Strict
import Data.ByteString qualified as BS
import Data.Text (Text)
import Data.Text.IO qualified as T
import qualified Data.Map.Strict as M
import Data.Text.Encoding qualified as T
import Data.Map.Strict qualified as M

import Data.Aeson (ToJSON, toJSON, (.=))
import qualified Data.Aeson as A
import Data.Aeson qualified as A
import Data.Text.Prettyprint.Doc
import System.Directory (getModificationTime)

Expand Down Expand Up @@ -317,7 +318,7 @@ forkWatchFile fname chan = onmod fname $ sendFileContents fname chan
sendFileContents :: String -> PChan Text -> IO ()
sendFileContents fname chan = do
putStrLn $ fname ++ " updated"
s <- T.readFile fname
s <- T.decodeUtf8 <$> BS.readFile fname
sendPChan chan s

onmod :: FilePath -> IO () -> IO ()
Expand Down

0 comments on commit d30ad52

Please sign in to comment.