[project @ 1998-12-02 13:17:09 by simonm]
[ghc-hetmet.git] / ghc / interpreter / library / UnicodePrims.hs
1 #ifdef HEAD
2 module UnicodePrims 
3         ( primUnicodeIsPrint
4         , primUnicodeIsUpper
5         , primUnicodeIsLower
6         , primUnicodeIsAlphaNum
7         ) where
8
9 import PreludeBuiltin
10 #endif /* HEAD */
11 #ifdef BODY
12
13 -- based on GHC's implementation
14 primUnicodeIsPrint    c = not (isControl c)
15 -- The upper case ISO characters have the multiplication sign dumped
16 -- randomly in the middle of the range.  Go figure.
17 primUnicodeIsUpper c    =  c >= 'A' && c <= 'Z' || 
18                            c >= '\xC0' && c <= '\xD6' ||
19                            c >= '\xD8' && c <= '\xDE'
20 -- The lower case ISO characters have the division sign dumped
21 -- randomly in the middle of the range.  Go figure.
22 primUnicodeIsLower c    =  c >= 'a' && c <= 'z' ||
23                            c >= '\xDF' && c <= '\xF6' ||
24                            c >= '\xF8' && c <= '\xFF'
25 primUnicodeIsAlphaNum c = isAlpha c  ||  isDigit c
26 primUnicodeToUpper    c 
27           | isLower c   = toEnum (fromEnum c - fromEnum 'a' + fromEnum 'A')
28           | otherwise   = c
29 primUnicodeToLower    c 
30           | isUpper c   = toEnum (fromEnum c - fromEnum 'A' + fromEnum 'a')
31           | otherwise   = c
32
33 #endif /* BODY */