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 #ifdef CONFIG_UCW_CLEAN_ABI
14 #define Uexpand_lig ucw_Uexpand_lig
15 #define _U_cat ucw__U_cat
16 #define _U_lower ucw__U_lower
17 #define _U_unaccent ucw__U_unaccent
18 #define _U_upper ucw__U_upper
21 extern const byte *_U_cat[];
22 extern const u16 *_U_upper[], *_U_lower[], *_U_unaccent[];
24 static inline uns Ucategory(uns x)
27 return _U_cat[x >> 8U][x & 0xff];
32 static inline uns Utoupper(uns x)
34 uns w = (_U_upper[x >> 8U]) ? _U_upper[x >> 8U][x & 0xff] : 0;
38 static inline uns Utolower(uns x)
40 uns w = (_U_lower[x >> 8U]) ? _U_lower[x >> 8U][x & 0xff] : 0;
44 static inline uns Uunaccent(uns x)
46 uns w = (_U_unaccent[x >> 8U]) ? _U_unaccent[x >> 8U][x & 0xff] : 0;
50 extern const u16 *Uexpand_lig(uns x);
52 enum unicode_char_type {
53 _U_LETTER = 1, /* Letters */
54 _U_UPPER = 2, /* Upper-case letters */
55 _U_LOWER = 4, /* Lower-case letters */
56 _U_CTRL = 8, /* Control characters */
57 _U_DIGIT = 16, /* Digits */
58 _U_XDIGIT = 32, /* Hexadecimal digits */
59 _U_SPACE = 64, /* White spaces (spaces, tabs, newlines) */
60 _U_LIGATURE = 128, /* Compatibility ligature (to be expanded) */
63 #define _U_LUPPER (_U_LETTER | _U_UPPER)
64 #define _U_LLOWER (_U_LETTER | _U_LOWER)
66 #define UCat(x,y) (Ucategory(x) & (y))
68 #define Ualpha(x) UCat(x, _U_LETTER)
69 #define Uupper(x) UCat(x, _U_UPPER)
70 #define Ulower(x) UCat(x, _U_LOWER)
71 #define Udigit(x) UCat(x, _U_DIGIT)
72 #define Uxdigit(x) UCat(x, (_U_DIGIT | _U_XDIGIT))
73 #define Ualnum(x) UCat(x, (_U_LETTER | _U_DIGIT))
74 #define Uctrl(x) UCat(x, _U_CTRL)
75 #define Uprint(x) !Uctrl(x)
76 #define Uspace(x) UCat(x, _U_SPACE)