From 60c2d054ee2e34014b081f331ced46b102d2fdbc Mon Sep 17 00:00:00 2001 From: krasimir Date: Fri, 27 Jun 2008 10:33:46 +0000 Subject: the shell now supports cp1251 coding with se command. works with the word completion as well --- src/GF/Text/CP1251.hs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/GF/Text/CP1251.hs (limited to 'src/GF/Text/CP1251.hs') 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 -- cgit v1.2.3