Skip to content

Commit

Permalink
fix: Always encode output as UTF-8 in cimplefmt.
Browse files Browse the repository at this point in the history
  • Loading branch information
iphydf committed Feb 4, 2022
1 parent 2e993c1 commit f96dd00
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions tools/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ haskell_binary(
deps = [
"//hs-cimple",
hazel_library("base"),
hazel_library("bytestring"),
hazel_library("text"),
],
)

Expand Down
14 changes: 12 additions & 2 deletions tools/cimplefmt.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
module Main (main) where

import qualified Data.ByteString as BS
import qualified Data.Text as Text
import qualified Data.Text.Encoding as Text
import Language.Cimple.IO (parseFile)
import Language.Cimple.Pretty (ppTranslationUnit)
import System.Environment (getArgs)
Expand All @@ -10,8 +13,15 @@ processFile source = do
putStrLn $ "Processing " ++ source
ast <- parseFile source
case ast of
Left err -> fail err
Right ok -> print $ ppTranslationUnit $ snd ok
Left err -> fail err
Right ok ->
BS.putStr
. Text.encodeUtf8
. Text.pack
. show
. ppTranslationUnit
. snd
$ ok


main :: IO ()
Expand Down

0 comments on commit f96dd00

Please sign in to comment.