summaryrefslogtreecommitdiff
path: root/src/GF/Text/Hebrew.hs
blob: 6c7db2677584d1541ec9845f08d8bc835b8fd0e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
----------------------------------------------------------------------
-- |
-- Module      : Hebrew
-- Maintainer  : (Maintainer)
-- Stability   : (stable)
-- Portability : (portable)
--
-- > CVS $Date: 2005/02/18 19:21:14 $ 
-- > CVS $Author: peb $
-- > CVS $Revision: 1.7 $
--
-- (Description of the module)
-----------------------------------------------------------------------------

module Hebrew (mkHebrew) where

mkHebrew :: String -> String
mkHebrew = mkHebrewWord
----mkHebrew = reverse . mkHebrewWord
--- reverse : assumes everything's on same line

type HebrewChar = Char

-- HH 031103 added code for spooling the markup
-- removed reverse, words, unwords 
-- (seemed obsolete and come out wrong on the screen)
-- AR 26/1/2004 put reverse back - needed in Fudgets (but not in Java?)

mkHebrewWord :: String -> [HebrewChar]
-- mkHebrewWord = map mkHebrewChar

mkHebrewWord s = case s of 
  [] -> [] 
  '<' : cs -> '<' : spoolMarkup cs
  ' ' : cs -> ' ' : mkHebrewWord cs
  c1 : cs -> mkHebrewChar c1 : mkHebrewWord cs

spoolMarkup :: String -> String
spoolMarkup s = case s of
  [] -> [] -- Shouldn't happen
  '>' : cs -> '>' : mkHebrewWord cs  
  c1 : cs -> c1 : spoolMarkup cs

mkHebrewChar c = case lookup c cc of Just c' -> c' ; _ -> c 
 where 
   cc = zip allHebrewCodes allHebrew

allHebrewCodes = "-abgdhwzHTyKklMmNnSoPpCcqrst"

allHebrew :: String
allHebrew = (map toEnum (0x05be : [0x05d0 .. 0x05ea]))