2 * The UniCode Character Categorizer
4 * (c) 1997--2004 Martin Mares <mj@ucw.cz>
6 * This software may be freely distributed and used according to the terms
7 * of the GNU Lesser General Public License.
10 #ifndef _CHARSET_UNICAT_H
11 #define _CHARSET_UNICAT_H
13 extern const byte *_U_cat[];
14 extern const u16 *_U_upper[], *_U_lower[], *_U_unaccent[];
16 static inline uns Ucategory(uns x)
19 return _U_cat[x >> 8U][x & 0xff];
24 static inline uns Utoupper(uns x)
26 uns w = (_U_upper[x >> 8U]) ? _U_upper[x >> 8U][x & 0xff] : 0;
30 static inline uns Utolower(uns x)
32 uns w = (_U_lower[x >> 8U]) ? _U_lower[x >> 8U][x & 0xff] : 0;
36 static inline uns Uunaccent(uns x)
38 uns w = (_U_unaccent[x >> 8U]) ? _U_unaccent[x >> 8U][x & 0xff] : 0;
42 extern const u16 *Uexpand_lig(uns x);
44 enum unicode_char_type {
45 _U_LETTER = 1, /* Letters */
46 _U_UPPER = 2, /* Upper-case letters */
47 _U_LOWER = 4, /* Lower-case letters */
48 _U_CTRL = 8, /* Control characters */
49 _U_DIGIT = 16, /* Digits */
50 _U_XDIGIT = 32, /* Hexadecimal digits */
51 _U_SPACE = 64, /* White spaces (spaces, tabs, newlines) */
52 _U_LIGATURE = 128, /* Compatibility ligature (to be expanded) */
55 #define _U_LUPPER (_U_LETTER | _U_UPPER)
56 #define _U_LLOWER (_U_LETTER | _U_LOWER)
58 #define UCat(x,y) (Ucategory(x) & (y))
60 #define Ualpha(x) UCat(x, _U_LETTER)
61 #define Uupper(x) UCat(x, _U_UPPER)
62 #define Ulower(x) UCat(x, _U_LOWER)
63 #define Udigit(x) UCat(x, _U_DIGIT)
64 #define Uxdigit(x) UCat(x, (_U_DIGIT | _U_XDIGIT))
65 #define Ualnum(x) UCat(x, (_U_LETTER | _U_DIGIT))
66 #define Uctrl(x) UCat(x, _U_CTRL)
67 #define Uprint(x) !Uctrl(x)
68 #define Uspace(x) UCat(x, _U_SPACE)