New module 'unictype/category-LC'.
[gnulib.git] / lib / unictype / categ_byname.c
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.
4
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.
9
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.
14
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/>.  */
17
18 #include <config.h>
19
20 /* Specification.  */
21 #include "unictype.h"
22
23 uc_general_category_t
24 uc_general_category_byname (const char *category_name)
25 {
26   if (category_name[0] != '\0'
27       && (category_name[1] == '\0' || category_name[2] == '\0'))
28     switch (category_name[0])
29       {
30       case 'L':
31         switch (category_name[1])
32           {
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;
40           }
41         break;
42       case 'M':
43         switch (category_name[1])
44           {
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;
49           }
50         break;
51       case 'N':
52         switch (category_name[1])
53           {
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;
58           }
59         break;
60       case 'P':
61         switch (category_name[1])
62           {
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;
71           }
72         break;
73       case 'S':
74         switch (category_name[1])
75           {
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;
81           }
82         break;
83       case 'Z':
84         switch (category_name[1])
85           {
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;
90           }
91         break;
92       case 'C':
93         switch (category_name[1])
94           {
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;
101           }
102         break;
103       }
104   /* Invalid category name.  */
105   return _UC_CATEGORY_NONE;
106 }