3 GeneralCategory(..), generalCategory, isPrint, isUpper
6 #if __GLASGOW_HASKELL__ > 604
8 import Data.Char (GeneralCategory(..), generalCategory,isPrint,isUpper)
12 import Foreign.C ( CInt )
13 import Data.Char ( ord )
15 -- | Unicode General Categories (column 2 of the UnicodeData table)
16 -- in the order they are listed in the Unicode standard.
19 = UppercaseLetter -- Lu Letter, Uppercase
20 | LowercaseLetter -- Ll Letter, Lowercase
21 | TitlecaseLetter -- Lt Letter, Titlecase
22 | ModifierLetter -- Lm Letter, Modifier
23 | OtherLetter -- Lo Letter, Other
24 | NonSpacingMark -- Mn Mark, Non-Spacing
25 | SpacingCombiningMark -- Mc Mark, Spacing Combining
26 | EnclosingMark -- Me Mark, Enclosing
27 | DecimalNumber -- Nd Number, Decimal
28 | LetterNumber -- Nl Number, Letter
29 | OtherNumber -- No Number, Other
30 | ConnectorPunctuation -- Pc Punctuation, Connector
31 | DashPunctuation -- Pd Punctuation, Dash
32 | OpenPunctuation -- Ps Punctuation, Open
33 | ClosePunctuation -- Pe Punctuation, Close
34 | InitialQuote -- Pi Punctuation, Initial quote
35 | FinalQuote -- Pf Punctuation, Final quote
36 | OtherPunctuation -- Po Punctuation, Other
37 | MathSymbol -- Sm Symbol, Math
38 | CurrencySymbol -- Sc Symbol, Currency
39 | ModifierSymbol -- Sk Symbol, Modifier
40 | OtherSymbol -- So Symbol, Other
41 | Space -- Zs Separator, Space
42 | LineSeparator -- Zl Separator, Line
43 | ParagraphSeparator -- Zp Separator, Paragraph
44 | Control -- Cc Other, Control
45 | Format -- Cf Other, Format
46 | Surrogate -- Cs Other, Surrogate
47 | PrivateUse -- Co Other, Private Use
48 | NotAssigned -- Cn Other, Not Assigned
49 deriving (Eq, Ord, Enum, Read, Show, Bounded)
51 -- | Retrieves the general Unicode category of the character.
52 generalCategory :: Char -> GeneralCategory
53 generalCategory c = toEnum $ fromIntegral $ wgencat $ fromIntegral $ ord c
55 foreign import ccall unsafe "u_gencat"
56 wgencat :: CInt -> CInt
58 isPrint :: Char -> Bool
59 isPrint c = iswprint (fromIntegral (ord c)) /= 0
61 isUpper :: Char -> Bool
62 isUpper c = iswupper (fromIntegral (ord c)) /= 0
64 foreign import ccall unsafe "u_iswprint"
65 iswprint :: CInt -> CInt
67 foreign import ccall unsafe "u_iswupper"
68 iswupper :: CInt -> CInt