From f3bee9fd3630caf3299597ddca9bbb34cacf4d66 Mon Sep 17 00:00:00 2001 From: krasimir Date: Wed, 28 Apr 2010 17:37:53 +0000 Subject: [PATCH] wf,vt,vp,vd,aw should store files in utf8 --- src/compiler/GF/Command/Commands.hs | 10 +++++----- src/compiler/GF/Infra/UseIO.hs | 7 +++++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/compiler/GF/Command/Commands.hs b/src/compiler/GF/Command/Commands.hs index 92590a403..5aaa62aca 100644 --- a/src/compiler/GF/Command/Commands.hs +++ b/src/compiler/GF/Command/Commands.hs @@ -155,7 +155,7 @@ allCommands env@(pgf, mos) = Map.fromList [ let file s = "_grph." ++ s let view = optViewGraph opts let format = optViewFormat opts - writeFile (file "dot") grph + writeUTF8File (file "dot") grph system $ "dot -T" ++ format ++ " " ++ file "dot" ++ " > " ++ file format system $ view ++ " " ++ file format return void @@ -737,7 +737,7 @@ allCommands env@(pgf, mos) = Map.fromList [ let file s = "_grphd." ++ s let view = optViewGraph opts let format = optViewFormat opts - writeFile (file "dot") grphs + writeUTF8File (file "dot") grphs system $ "dot -T" ++ format ++ " " ++ file "dot" ++ " > " ++ file format system $ view ++ " " ++ file format return void @@ -778,7 +778,7 @@ allCommands env@(pgf, mos) = Map.fromList [ let file s = "_grph." ++ s let view = optViewGraph opts let format = optViewFormat opts - writeFile (file "dot") grph + writeUTF8File (file "dot") grph system $ "dot -T" ++ format ++ " " ++ file "dot" ++ " > " ++ file format system $ view ++ " " ++ file format return void @@ -818,7 +818,7 @@ allCommands env@(pgf, mos) = Map.fromList [ let file s = "_grph." ++ s let view = optViewGraph opts let format = optViewFormat opts - writeFile (file "dot") grph + writeUTF8File (file "dot") grph system $ "dot -T" ++ format ++ " " ++ file "dot" ++ " > " ++ file format system $ view ++ " " ++ file format return void @@ -844,7 +844,7 @@ allCommands env@(pgf, mos) = Map.fromList [ let file = valStrOpts "file" "_gftmp" opts if isOpt "append" opts then appendFile file (toString arg) - else writeFile file (toString arg) + else writeUTF8File file (toString arg) return void, options = [ ("append","append to file, instead of overwriting it") diff --git a/src/compiler/GF/Infra/UseIO.hs b/src/compiler/GF/Infra/UseIO.hs index bb1a75b6e..3940e6be1 100644 --- a/src/compiler/GF/Infra/UseIO.hs +++ b/src/compiler/GF/Infra/UseIO.hs @@ -184,3 +184,10 @@ putPointE v opts msg act = do else when (verbAtLeast opts v) $ putStrLnE "" return a + +writeUTF8File :: FilePath -> String -> IO () +writeUTF8File fpath content = do + h <- openFile fpath WriteMode + hSetEncoding h utf8 + hPutStr h content + hClose h