Skip to content

Commit

Permalink
[#164] Use utf8-compatible codepage on Windows
Browse files Browse the repository at this point in the history
Problem: xrefcheck uses utf8 symbols in reports, which are not supported
on most of Windows shells by default.
Sometimes they are printed as question marks (and it cause golden tests to fail)
and sometimes printing of them raise an error.

Solution: use function `withCP65001` from `code-page` package which
sets correct codepage on Windows and do nothing on other OSs
  • Loading branch information
Sorokin-Anton committed Nov 3, 2022
1 parent 543749a commit 5a85e0c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ library:
- uri-bytestring
- yaml
- reflection
- code-page

executables:
xrefcheck:
Expand Down
3 changes: 2 additions & 1 deletion src/Xrefcheck/Command.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Data.Yaml (decodeFileEither, prettyPrintParseException)
import Fmt (blockListF', build, fmt, fmtLn, indentF)
import System.Console.Pretty (supportsPretty)
import System.Directory (doesFileExist)
import System.IO.CodePage (withCP65001)

import Xrefcheck.CLI (Options (..), addExclusionOptions, addNetworkingOptions, defaultConfigPaths)
import Xrefcheck.Config
Expand Down Expand Up @@ -46,7 +47,7 @@ findFirstExistingFile = \case
if exists then pure (Just file) else findFirstExistingFile files

defaultAction :: Options -> IO ()
defaultAction Options{..} = do
defaultAction Options{..} = withCP65001 $ do
coloringSupported <- supportsPretty
give (if coloringSupported then oColorMode else WithoutColors) $ do
config <- case oConfigPath of
Expand Down

0 comments on commit 5a85e0c

Please sign in to comment.