summaryrefslogtreecommitdiff
path: root/src/GF
diff options
context:
space:
mode:
Diffstat (limited to 'src/GF')
-rw-r--r--src/GF/Shell/CommandL.hs9
-rw-r--r--src/GF/Shell/Commands.hs9
-rw-r--r--src/GF/Shell/JGF.hs2
3 files changed, 16 insertions, 4 deletions
diff --git a/src/GF/Shell/CommandL.hs b/src/GF/Shell/CommandL.hs
index 36e8a5a6d..2bb240018 100644
--- a/src/GF/Shell/CommandL.hs
+++ b/src/GF/Shell/CommandL.hs
@@ -44,10 +44,13 @@ getCommand = do
s <- getLine
return $ pCommand s
-getCommandUTF :: IO Command
-getCommandUTF = do
+-- decodes UTF8 if u==False, i.e. if the grammar does not use UTF8;
+-- used in the Java GUI, which always uses UTF8
+
+getCommandUTF :: Bool -> IO Command
+getCommandUTF u = do
s <- getLine
- return $ pCommand s -- the GUI is doing this: $ decodeUTF8 s
+ return $ pCommand $ if u then s else decodeUTF8 s
pCommand = pCommandWords . words where
pCommandWords s = case s of
diff --git a/src/GF/Shell/Commands.hs b/src/GF/Shell/Commands.hs
index 5a16c4b59..e96ebd588 100644
--- a/src/GF/Shell/Commands.hs
+++ b/src/GF/Shell/Commands.hs
@@ -441,6 +441,15 @@ displaySStateJavaX isNew env state = encodeUTF8 $ mkUnicode $
Just lang -> optDecodeUTF8 (stateGrammarOfLang env (language lang))
_ -> id
+-- the env is UTF8 if the display language is
+--- should be independent
+isCEnvUTF8 :: CEnv -> SState -> Bool
+isCEnvUTF8 env st = maybe False id $ do
+ lang <- getOptVal opts menuDisplay
+ co <- getOptVal (stateOptions (stateGrammarOfLang env (language lang))) uniCoding
+ return $ co == "utf8"
+ where
+ opts = addOptions (optsSState st) (globalOptions env)
langAbstract = language "Abstract"
langXML = language "XML"
diff --git a/src/GF/Shell/JGF.hs b/src/GF/Shell/JGF.hs
index 44b6aad2b..f1ed6bfb7 100644
--- a/src/GF/Shell/JGF.hs
+++ b/src/GF/Shell/JGF.hs
@@ -29,7 +29,7 @@ sessionLineJ isNew env = do
---- the Boolean is a temporary hack to have two parallel GUIs
editLoopJnewX :: Bool -> CEnv -> SState -> IO ()
editLoopJnewX isNew env state = do
- c <- getCommandUTF
+ c <- getCommandUTF (isCEnvUTF8 env state) ----
case c of
CQuit -> return ()