summaryrefslogtreecommitdiff
path: root/src/compiler/SimpleEditor/Convert.hs
diff options
context:
space:
mode:
authorhallgren <hallgren@chalmers.se>2012-10-09 13:14:18 +0000
committerhallgren <hallgren@chalmers.se>2012-10-09 13:14:18 +0000
commitf53ab8b3535d32044386be55127f30e96f691e92 (patch)
tree7fd3dabfe0c6856d01fd8db6254efa8c9d0e26bf /src/compiler/SimpleEditor/Convert.hs
parentc4faf2dddd718db019adc7cdff8fc39b5b7f1615 (diff)
gf -server: /parse command now supports input with character codes > 255
This enables the use of arbitrary Unicode character in text mode in GFSE.
Diffstat (limited to 'src/compiler/SimpleEditor/Convert.hs')
-rw-r--r--src/compiler/SimpleEditor/Convert.hs11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/compiler/SimpleEditor/Convert.hs b/src/compiler/SimpleEditor/Convert.hs
index e6cb98124..6368772aa 100644
--- a/src/compiler/SimpleEditor/Convert.hs
+++ b/src/compiler/SimpleEditor/Convert.hs
@@ -5,10 +5,15 @@ import Control.Monad(unless,foldM,ap,mplus)
import Data.List(sortBy)
import Data.Function(on)
import qualified Data.Map as Map
-import qualified Data.ByteString.Char8 as BS(pack)
import Text.JSON(encode,makeObj)
import Text.PrettyPrint(render)
+-- 4 extra imports just to deal with the ByteString mess...
+import qualified Data.ByteString.Char8 as BS(pack)
+import Codec.Binary.UTF8.String(encodeString)
+import GF.Compile.Coding(decodeStringsInModule)
+import System.IO(utf8)
+
--import GF.Compile.GetGrammar (getSourceModule)
import GF.Infra.Option(optionsGFO)
import GF.Infra.Ident(showIdent)
@@ -25,10 +30,10 @@ import SimpleEditor.JSON
parseModule (path,source) =
(path.=) $
- case runP pModDef (BS.pack source) of
+ case runP pModDef (BS.pack (encodeString source)) of
Left (Pn l c,msg) ->
makeObj ["error".=msg, "location".= show l++":"++show c]
- Right mod -> case convModule mod of
+ Right mod -> case convModule (decodeStringsInModule utf8 mod) of
Ok g -> makeObj ["converted".=g]
Bad msg -> makeObj ["parsed".=msg]