mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-15 07:49:31 -06:00
the shell now supports cp1251 coding with se command. works with the word completion as well
This commit is contained in:
@@ -3,6 +3,7 @@ module GF.Compile.Coding where
|
||||
import GF.Grammar.Grammar
|
||||
import GF.Grammar.Macros
|
||||
import GF.Text.UTF8
|
||||
import GF.Text.CP1251
|
||||
import GF.Infra.Modules
|
||||
import GF.Infra.Option
|
||||
import GF.Data.Operations
|
||||
@@ -47,9 +48,3 @@ codeSourceModule co (id,moi) = case moi of
|
||||
PSeq p q -> PSeq (codp p) (codp q)
|
||||
PAlt p q -> PAlt (codp p) (codp q)
|
||||
_ -> p
|
||||
|
||||
---- from Text.Lexing
|
||||
decodeCP1251 = map convert where
|
||||
convert c
|
||||
| c >= '\192' && c <= '\255' = chr (ord c + 848)
|
||||
| otherwise = c
|
||||
|
||||
18
src/GF/Text/CP1251.hs
Normal file
18
src/GF/Text/CP1251.hs
Normal file
@@ -0,0 +1,18 @@
|
||||
module GF.Text.CP1251 where
|
||||
|
||||
import Data.Char
|
||||
|
||||
decodeCP1251 = map convert where
|
||||
convert c
|
||||
| c >= '\192' && c <= '\255' = chr (ord c + 848)
|
||||
| c == '\168' = chr 1025 -- cyrillic capital letter lo
|
||||
| c == '\184' = chr 1105 -- cyrillic small letter lo
|
||||
| otherwise = c
|
||||
|
||||
encodeCP1251 = map convert where
|
||||
convert c
|
||||
| oc >= 1040 && oc <= 1103 = chr (oc - 848)
|
||||
| oc == 1025 = chr 168 -- cyrillic capital letter lo
|
||||
| oc == 1105 = chr 184 -- cyrillic small letter lo
|
||||
| otherwise = c
|
||||
where oc = ord c
|
||||
@@ -2,6 +2,7 @@ module GF.Text.Lexing (stringOp) where
|
||||
|
||||
import GF.Text.Transliterations
|
||||
import GF.Text.UTF8
|
||||
import GF.Text.CP1251
|
||||
|
||||
import Data.Char
|
||||
import Data.List (intersperse)
|
||||
@@ -98,18 +99,3 @@ unlexMixed = concat . alternate False where
|
||||
isPunct = flip elem ".?!,:;"
|
||||
isParen = flip elem "()[]{}"
|
||||
isClosing = flip elem ")]}"
|
||||
|
||||
|
||||
-- might be in a file of its own: Windows Cyrillic, used in Bulgarian resource
|
||||
|
||||
decodeCP1251 = map convert where
|
||||
convert c
|
||||
| c >= '\192' && c <= '\255' = chr (ord c + 848)
|
||||
| otherwise = c
|
||||
|
||||
encodeCP1251 = map convert where
|
||||
convert c
|
||||
| oc >= 1040 && oc <= 1103 = chr (oc - 848)
|
||||
| otherwise = c
|
||||
where oc = ord c
|
||||
|
||||
|
||||
Reference in New Issue
Block a user