diff --git a/src/GF/Compile/Compile.hs b/src/GF/Compile/Compile.hs index faece6a99..856544152 100644 --- a/src/GF/Compile/Compile.hs +++ b/src/GF/Compile/Compile.hs @@ -53,6 +53,7 @@ import GF.Canon.GetGFC import GF.Data.Operations import GF.Infra.UseIO +import GF.Text.UTF8 ---- import GF.System.Arch import Control.Monad @@ -338,9 +339,12 @@ generateModuleCode opts path minfo@(name,info) = do let (file,out) = (gfrFile pname, prGrammar (MGrammar [rminfo])) putp (" wrote file" +++ file) $ ioeIO $ writeFile file $ compactPrint out _ -> return () + let encode = case getOptVal opts uniCoding of + Just "utf8" -> encodeUTF8 + _ -> id (file,out) <- do code <- return $ MkGFC.prCanonModInfo minfo' - return (gfcFile pname, code) + return (gfcFile pname, encode code) if emit && nomulti ---- && isCompilable info then putp (" wrote file" +++ file) $ ioeIO $ writeFile file out else putpp ("no need to save module" +++ prt name) $ return () diff --git a/src/GF/Compile/GetGrammar.hs b/src/GF/Compile/GetGrammar.hs index d9afc9546..2b908bd81 100644 --- a/src/GF/Compile/GetGrammar.hs +++ b/src/GF/Compile/GetGrammar.hs @@ -29,6 +29,7 @@ import qualified GF.Source.AbsGF as A import GF.Source.SourceToGrammar ---- import Macros ---- import Rename +import GF.Text.UTF8 ---- import GF.Infra.Option --- import Custom import GF.Source.ParGF @@ -56,7 +57,10 @@ getSourceModule opts file0 = do -- ioeIO $ putStrLn $ "preproc" +++ cmd return tmp _ -> return file0 - string <- readFileIOE file + string0 <- readFileIOE file + let string = case getOptVal opts uniCoding of + Just "utf8" -> decodeUTF8 string0 + _ -> string0 let tokens = myLexer string mo1 <- ioeErr $ {- err2err $ -} pModDef tokens ioeErr $ transModDef mo1