diff options
| author | krasimir <krasimir@chalmers.se> | 2008-06-27 10:33:46 +0000 |
|---|---|---|
| committer | krasimir <krasimir@chalmers.se> | 2008-06-27 10:33:46 +0000 |
| commit | 60c2d054ee2e34014b081f331ced46b102d2fdbc (patch) | |
| tree | f228229437cdad25f20d210348fad2506223f7e0 /src/GF/Text | |
| parent | 5c713d8f027a9b6be687ee3f7e917e8bd2115773 (diff) | |
the shell now supports cp1251 coding with se command. works with the word completion as well
Diffstat (limited to 'src/GF/Text')
| -rw-r--r-- | src/GF/Text/CP1251.hs | 18 | ||||
| -rw-r--r-- | src/GF/Text/Lexing.hs | 16 |
2 files changed, 19 insertions, 15 deletions
diff --git a/src/GF/Text/CP1251.hs b/src/GF/Text/CP1251.hs new file mode 100644 index 000000000..af5c829a2 --- /dev/null +++ b/src/GF/Text/CP1251.hs @@ -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
diff --git a/src/GF/Text/Lexing.hs b/src/GF/Text/Lexing.hs index 2c6b417b8..38018ff54 100644 --- a/src/GF/Text/Lexing.hs +++ b/src/GF/Text/Lexing.hs @@ -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 - |
