From 0a41af38169035a4359c0c29bc1219af564dce64 Mon Sep 17 00:00:00 2001 From: simonmar Date: Mon, 14 Mar 2005 15:22:51 +0000 Subject: [PATCH] [project @ 2005-03-14 15:22:51 by simonmar] - isDigit only returns True for ASCII digits - Export the new predicates from Data.Char --- Data/Char.hs | 10 ++++++---- GHC/Unicode.hs | 9 +++++++-- cbits/WCsubst.c | 1 - 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Data/Char.hs b/Data/Char.hs index 1debe79..2ec1e66 100644 --- a/Data/Char.hs +++ b/Data/Char.hs @@ -23,14 +23,16 @@ module Data.Char -- | Unicode characters are divided into letters, numbers, marks, -- punctuation, symbols, separators (including spaces) and others -- (including control characters). - -- The full set of Unicode character attributes is not accessible - -- in this library. , isAscii, isLatin1, isControl, isSpace , isLower, isUpper, isAlpha, isAlphaNum, isPrint - , isDigit, isOctDigit, isHexDigit -- :: Char -> Bool + , isDigit, isOctDigit, isHexDigit + , isAsciiUpper, isAsciiLower + , isLetter, isMark, isNumber, isPunctuation, isSymbol, isSeparator + + , GeneralCategory(..), generalCategory -- * Case conversion - , toUpper, toLower -- :: Char -> Char + , toUpper, toLower, toTitle -- :: Char -> Char -- * Single digit characters , digitToInt -- :: Char -> Int diff --git a/GHC/Unicode.hs b/GHC/Unicode.hs index 8aefad5..6a4732b 100644 --- a/GHC/Unicode.hs +++ b/GHC/Unicode.hs @@ -195,6 +195,7 @@ isAlphaNum :: Char -> Bool -- | Selects ASCII digits, i.e. @\'0\'@..@\'9\'@. isDigit :: Char -> Bool +isDigit c = c >= '0' && c <= '9' -- | Selects ASCII octal digits, i.e. @\'0\'@..@\'7\'@. isOctDigit :: Char -> Bool @@ -216,6 +217,11 @@ toUpper :: Char -> Char -- equivalent is transformed. toLower :: Char -> Char +-- | Convert a letter to the corresponding title-case letter, leaving any +-- other character unchanged. Any Unicode letter which has a lower-case +-- equivalent is transformed. +toTitle :: Char -> Char + -- ----------------------------------------------------------------------------- -- Implementation with the supplied auto-generated Unicode character properties -- table (default) @@ -225,8 +231,8 @@ toLower :: Char -> Char -- Regardless of the O/S and Library, use the functions contained in WCsubst.c type WInt = HTYPE_WINT_T +type CInt = HTYPE_INT -isDigit c = iswdigit (fromIntegral (ord c)) /= 0 isAlpha c = iswalpha (fromIntegral (ord c)) /= 0 isAlphaNum c = iswalnum (fromIntegral (ord c)) /= 0 --isSpace c = iswspace (fromIntegral (ord c)) /= 0 @@ -295,7 +301,6 @@ isLower c = c >= 'a' && c <= 'z' || c >= '\xF8' && c <= '\xFF' isAlpha c = isLower c || isUpper c -isDigit c = c >= '0' && c <= '9' isAlphaNum c = isAlpha c || isDigit c -- Case-changing operations diff --git a/cbits/WCsubst.c b/cbits/WCsubst.c index 18752b9..d63e0ea 100644 --- a/cbits/WCsubst.c +++ b/cbits/WCsubst.c @@ -3070,7 +3070,6 @@ unipred_s(u_iswspace,GENCAT_ZS) unipred(u_iswupper,(GENCAT_LU|GENCAT_LT)) unipred(u_iswlower,GENCAT_LL) unipred(u_iswalpha,(GENCAT_LL|GENCAT_LU|GENCAT_LT|GENCAT_LM|GENCAT_LO)) -unipred(u_iswdigit,GENCAT_ND) unipred(u_iswalnum,(GENCAT_LT|GENCAT_LU|GENCAT_LL|GENCAT_LM|GENCAT_LO| GENCAT_MC|GENCAT_ME|GENCAT_MN| -- 1.7.10.4