1 /* Categories of Unicode characters.
2 Copyright (C) 2002, 2006-2007, 2011 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2002.
5 This program is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Lesser General Public License as published
7 by the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
24 uc_general_category_byname (const char *category_name)
26 if (category_name[0] != '\0'
27 && (category_name[1] == '\0' || category_name[2] == '\0'))
28 switch (category_name[0])
31 switch (category_name[1])
33 case '\0': return UC_CATEGORY_L;
34 case 'C': return UC_CATEGORY_LC;
35 case 'u': return UC_CATEGORY_Lu;
36 case 'l': return UC_CATEGORY_Ll;
37 case 't': return UC_CATEGORY_Lt;
38 case 'm': return UC_CATEGORY_Lm;
39 case 'o': return UC_CATEGORY_Lo;
43 switch (category_name[1])
45 case '\0': return UC_CATEGORY_M;
46 case 'n': return UC_CATEGORY_Mn;
47 case 'c': return UC_CATEGORY_Mc;
48 case 'e': return UC_CATEGORY_Me;
52 switch (category_name[1])
54 case '\0': return UC_CATEGORY_N;
55 case 'd': return UC_CATEGORY_Nd;
56 case 'l': return UC_CATEGORY_Nl;
57 case 'o': return UC_CATEGORY_No;
61 switch (category_name[1])
63 case '\0': return UC_CATEGORY_P;
64 case 'c': return UC_CATEGORY_Pc;
65 case 'd': return UC_CATEGORY_Pd;
66 case 's': return UC_CATEGORY_Ps;
67 case 'e': return UC_CATEGORY_Pe;
68 case 'i': return UC_CATEGORY_Pi;
69 case 'f': return UC_CATEGORY_Pf;
70 case 'o': return UC_CATEGORY_Po;
74 switch (category_name[1])
76 case '\0': return UC_CATEGORY_S;
77 case 'm': return UC_CATEGORY_Sm;
78 case 'c': return UC_CATEGORY_Sc;
79 case 'k': return UC_CATEGORY_Sk;
80 case 'o': return UC_CATEGORY_So;
84 switch (category_name[1])
86 case '\0': return UC_CATEGORY_Z;
87 case 's': return UC_CATEGORY_Zs;
88 case 'l': return UC_CATEGORY_Zl;
89 case 'p': return UC_CATEGORY_Zp;
93 switch (category_name[1])
95 case '\0': return UC_CATEGORY_C;
96 case 'c': return UC_CATEGORY_Cc;
97 case 'f': return UC_CATEGORY_Cf;
98 case 's': return UC_CATEGORY_Cs;
99 case 'o': return UC_CATEGORY_Co;
100 case 'n': return UC_CATEGORY_Cn;
104 /* Invalid category name. */
105 return _UC_CATEGORY_NONE;