1 /* Copyright (c) 2000, 2001, 2003 MySQL AB
2    Use is subject to license terms
3 
4    This program is free software; you can redistribute it and/or modify
5    it under the terms of the GNU General Public License, version 2.0,
6    as published by the Free Software Foundation.
7 
8    This program is also distributed with certain software (including
9    but not limited to OpenSSL) that is licensed under separate terms,
10    as designated in a particular file or component or in included license
11    documentation.  The authors of MySQL hereby grant you an additional
12    permission to link the program and your derivative works with the
13    separately licensed software that they have included with MySQL.
14 
15    This program is distributed in the hope that it will be useful,
16    but WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18    GNU General Public License, version 2.0, for more details.
19 
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA */
23 
24 /*
25   Copyright (C) 1998, 1999 by Pruet Boonma, all rights reserved.
26   Copyright (C) 1998 by Theppitak Karoonboonyanan, all rights reserved.
27   Permission to use, copy, modify, distribute and sell this software
28    and its documentation for any purpose is hereby granted without fee,
29    provided that the above copyright notice appear in all copies.
30    Smaphan Raruenrom and Pruet Boonma makes no representations about
31    the suitability of this software for any purpose.  It is provided
32     "as is" without express or implied warranty.
33 */
34 
35 /*
36   LC_COLLATE category + Level information
37 */
38 
39 #ifndef _t_ctype_h
40 #define _t_ctype_h
41 
42 typedef unsigned char tchar;
43 
44 #define TOT_LEVELS 5
45 #define LAST_LEVEL 4 /* TOT_LEVELS - 1 */
46 
47 #define IGNORE 0
48 
49 /* level 1 symbols & order */
50 enum l1_symbols {
51   L1_08 = TOT_LEVELS,
52   L1_18,
53   L1_28,
54   L1_38,
55   L1_48,
56   L1_58,
57   L1_68,
58   L1_78,
59   L1_88,
60   L1_98,
61   L1_A8,
62   L1_B8,
63   L1_C8,
64   L1_D8,
65   L1_E8,
66   L1_F8,
67   L1_G8,
68   L1_H8,
69   L1_I8,
70   L1_J8,
71   L1_K8,
72   L1_L8,
73   L1_M8,
74   L1_N8,
75   L1_O8,
76   L1_P8,
77   L1_Q8,
78   L1_R8,
79   L1_S8,
80   L1_T8,
81   L1_U8,
82   L1_V8,
83   L1_W8,
84   L1_X8,
85   L1_Y8,
86   L1_Z8,
87   L1_KO_KAI,
88   L1_KHO_KHAI,
89   L1_KHO_KHUAT,
90   L1_KHO_KHWAI,
91   L1_KHO_KHON,
92   L1_KHO_RAKHANG,
93   L1_NGO_NGU,
94   L1_CHO_CHAN,
95   L1_CHO_CHING,
96   L1_CHO_CHANG,
97   L1_SO_SO,
98   L1_CHO_CHOE,
99   L1_YO_YING,
100   L1_DO_CHADA,
101   L1_TO_PATAK,
102   L1_THO_THAN,
103   L1_THO_NANGMONTHO,
104   L1_THO_PHUTHAO,
105   L1_NO_NEN,
106   L1_DO_DEK,
107   L1_TO_TAO,
108   L1_THO_THUNG,
109   L1_THO_THAHAN,
110   L1_THO_THONG,
111   L1_NO_NU,
112   L1_BO_BAIMAI,
113   L1_PO_PLA,
114   L1_PHO_PHUNG,
115   L1_FO_FA,
116   L1_PHO_PHAN,
117   L1_FO_FAN,
118   L1_PHO_SAMPHAO,
119   L1_MO_MA,
120   L1_YO_YAK,
121   L1_RO_RUA,
122   L1_RU,
123   L1_LO_LING,
124   L1_LU,
125   L1_WO_WAEN,
126   L1_SO_SALA,
127   L1_SO_RUSI,
128   L1_SO_SUA,
129   L1_HO_HIP,
130   L1_LO_CHULA,
131   L1_O_ANG,
132   L1_HO_NOKHUK,
133   L1_NKHIT,
134   L1_SARA_A,
135   L1_MAI_HAN_AKAT,
136   L1_SARA_AA,
137   L1_SARA_AM,
138   L1_SARA_I,
139   L1_SARA_II,
140   L1_SARA_UE,
141   L1_SARA_UEE,
142   L1_SARA_U,
143   L1_SARA_UU,
144   L1_SARA_E,
145   L1_SARA_AE,
146   L1_SARA_O,
147   L1_SARA_AI_MAIMUAN,
148   L1_SARA_AI_MAIMALAI
149 };
150 
151 /* level 2 symbols & order */
152 enum l2_symbols {
153   L2_BLANK = TOT_LEVELS,
154   L2_THAII,
155   L2_YAMAK,
156   L2_PINTHU,
157   L2_GARAN,
158   L2_TYKHU,
159   L2_TONE1,
160   L2_TONE2,
161   L2_TONE3,
162   L2_TONE4
163 };
164 
165 /* level 3 symbols & order */
166 enum l3_symbols {
167   L3_BLANK = TOT_LEVELS,
168   L3_SPACE,
169   L3_NB_SACE,
170   L3_LOW_LINE,
171   L3_HYPHEN,
172   L3_COMMA,
173   L3_SEMICOLON,
174   L3_COLON,
175   L3_EXCLAMATION,
176   L3_QUESTION,
177   L3_SOLIDUS,
178   L3_FULL_STOP,
179   L3_PAIYAN_NOI,
180   L3_MAI_YAMOK,
181   L3_GRAVE,
182   L3_CIRCUMFLEX,
183   L3_TILDE,
184   L3_APOSTROPHE,
185   L3_QUOTATION,
186   L3_L_PARANTHESIS,
187   L3_L_BRACKET,
188   L3_L_BRACE,
189   L3_R_BRACE,
190   L3_R_BRACKET,
191   L3_R_PARENTHESIS,
192   L3_AT,
193   L3_BAHT,
194   L3_DOLLAR,
195   L3_FONGMAN,
196   L3_ANGKHANKHU,
197   L3_KHOMUT,
198   L3_ASTERISK,
199   L3_BK_SOLIDUS,
200   L3_AMPERSAND,
201   L3_NUMBER,
202   L3_PERCENT,
203   L3_PLUS,
204   L3_LESS_THAN,
205   L3_EQUAL,
206   L3_GREATER_THAN,
207   L3_V_LINE
208 };
209 
210 /* level 4 symbols & order */
211 enum l4_symbols { L4_BLANK = TOT_LEVELS, L4_MIN, L4_CAP, L4_EXT };
212 
213 enum level_symbols { L_UPRUPR = TOT_LEVELS, L_UPPER, L_MIDDLE, L_LOWER };
214 
215 #define _is(c) (t_ctype[(c)][LAST_LEVEL])
216 #define _level 8
217 #define _consnt 16
218 #define _ldvowel 32
219 #define _fllwvowel 64
220 #define _uprvowel 128
221 #define _lwrvowel 256
222 #define _tone 512
223 #define _diacrt1 1024
224 #define _diacrt2 2048
225 #define _combine 4096
226 #define _stone 8192
227 #define _tdig 16384
228 #define _rearvowel (_fllwvowel | _uprvowel | _lwrvowel)
229 #define _diacrt (_diacrt1 | _diacrt2)
230 #define levelof(c) (_is(c) & _level)
231 #define isthai(c) ((c) >= 128)
232 #define istalpha(c) \
233   (_is(c) & (_consnt | _ldvowel | _rearvowel | _tone | _diacrt1 | _diacrt2))
234 #define isconsnt(c) (_is(c) & _consnt)
235 #define isldvowel(c) (_is(c) & _ldvowel)
236 #define isfllwvowel(c) (_is(c) & _fllwvowel)
237 #define ismidvowel(c) (_is(c) & (_ldvowel | _fllwvowel))
238 #define isuprvowel(c) (_is(c) & _uprvowel)
239 #define islwrvowel(c) (_is(c) & _lwrvowel)
240 #define isuprlwrvowel(c) (_is(c) & (_lwrvowel | _uprvowel))
241 #define isrearvowel(c) (_is(c) & _rearvowel)
242 #define isvowel(c) (_is(c) & (_ldvowel | _rearvowel))
243 #define istone(c) (_is(c) & _tone)
244 #define isunldable(c) (_is(c) & (_rearvowel | _tone | _diacrt1 | _diacrt2))
245 #define iscombinable(c) (_is(c) & _combine)
246 #define istdigit(c) (_is(c) & _tdig)
247 #define isstone(c) (_is(c) & _stone)
248 #define isdiacrt1(c) (_is(c) & _diacrt1)
249 #define isdiacrt2(c) (_is(c) & _diacrt2)
250 #define isdiacrt(c) (_is(c) & _diacrt)
251 
252 /* Function prototype called by sql/field.cc */
253 void ThNormalize(uchar *ptr, uint field_length, const uchar *from, uint length);
254 
255 #endif
256