summaryrefslogtreecommitdiff
path: root/testsuite/tests/lib/Char/unicode002.hs
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/lib/Char/unicode002.hs')
-rw-r--r--testsuite/tests/lib/Char/unicode002.hs44
1 files changed, 44 insertions, 0 deletions
diff --git a/testsuite/tests/lib/Char/unicode002.hs b/testsuite/tests/lib/Char/unicode002.hs
new file mode 100644
index 0000000000..50ed5ddf44
--- /dev/null
+++ b/testsuite/tests/lib/Char/unicode002.hs
@@ -0,0 +1,44 @@
+module Main where
+
+
+import Data.Char
+import Numeric
+
+header = "Code C P S U L A D"
+
+preds = [
+ isControl,
+ isPrint,
+ isSpace,
+ isUpper,
+ isLower,
+ isAlpha,
+ isDigit]
+
+prtBool :: Bool -> String
+
+prtBool True = "T "
+prtBool False = "F "
+
+showCode :: Char -> Int -> String
+
+showCode c w = code ++ pad
+ where
+ code = show (ord c)
+ l = length code
+ spaces = map anytospace [1..]
+ anytospace _ = ' '
+ pad | l >= w = ""
+ | otherwise = take (w - l) spaces
+
+charCode :: Char -> String
+
+rapply a b = b a
+
+charCode c = (showCode c 5) ++ (foldr1 (++) $ map prtBool $ map (rapply c) preds)
+
+main = do
+ putStrLn header
+ mapM (putStrLn . charCode) [ (chr 0) .. (chr 6553) ]
+
+