mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / strings / ctype-tis620.c
blobd42e5072feb01db0b29a1eee2b298b1e6f2cf6ac
1 /* Copyright (c) 2000-2007 MySQL AB
2 Use is subject to license terms.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; version 2 of the License.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 Copyright (C) 2003 by Sathit Jittanupat
20 <jsat66@hotmail.com,jsat66@yahoo.com>
21 * solving bug crash with long text field string
22 * sorting with different number of space or sign char. within string
24 Copyright (C) 2001 by Korakot Chaovavanich <korakot@iname.com> and
25 Apisilp Trunganont <apisilp@pantip.inet.co.th>
26 Copyright (C) 1998, 1999 by Pruet Boonma <pruet@eng.cmu.ac.th>
27 Copyright (C) 1998 by Theppitak Karoonboonyanan <thep@links.nectec.or.th>
28 Copyright (C) 1989, 1991 by Samphan Raruenrom <samphan@thai.com>
30 Permission to use, copy, modify, distribute and sell this software
31 and its documentation for any purpose is hereby granted without fee,
32 provided that the above copyright notice appear in all copies.
33 Samphan Raruenrom , Theppitak Karoonboonyanan , Pruet Boonma ,
34 Korakot Chaovavanich and Apisilp Trunganont makes no representations
35 about the suitability of this software for any purpose. It is provided
36 "as is" without express or implied warranty.
41 This file is basicly tis620 character sets with some extra functions
42 for tis-620 handling
46 * This comment is parsed by configure to create ctype.c,
47 * so don't change it unless you know what you are doing.
49 * .configure. strxfrm_multiply_tis620=4
52 #include <my_global.h>
53 #include <my_sys.h>
54 #include "m_string.h"
55 #include "m_ctype.h"
56 #include "t_ctype.h"
58 #ifdef HAVE_CHARSET_tis620
60 #define BUFFER_MULTIPLY 4
61 #define M L_MIDDLE
62 #define U L_UPPER
63 #define L L_LOWER
64 #define UU L_UPRUPR
65 #define X L_MIDDLE
68 static int t_ctype[][TOT_LEVELS] = {
69 /*0x00*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
70 /*0x01*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
71 /*0x02*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
72 /*0x03*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
73 /*0x04*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
74 /*0x05*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
75 /*0x06*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
76 /*0x07*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
77 /*0x08*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
78 /*0x09*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
79 /*0x0A*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
80 /*0x0B*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
81 /*0x0C*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
82 /*0x0D*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
83 /*0x0E*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
84 /*0x0F*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
85 /*0x10*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
86 /*0x11*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
87 /*0x12*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
88 /*0x13*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
89 /*0x14*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
90 /*0x15*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
91 /*0x16*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
92 /*0x17*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
93 /*0x18*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
94 /*0x19*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
95 /*0x1A*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
96 /*0x1B*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
97 /*0x1C*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
98 /*0x1D*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
99 /*0x1E*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
100 /*0x1F*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
101 /*0x20*/ { IGNORE, IGNORE, L3_SPACE, IGNORE, M},
102 /*0x21*/ { IGNORE, IGNORE, L3_EXCLAMATION, IGNORE, M },
103 /*0x22*/ { IGNORE, IGNORE, L3_QUOTATION, IGNORE, M },
104 /*0x23*/ { IGNORE, IGNORE, L3_NUMBER, IGNORE, M },
105 /*0x24*/ { IGNORE, IGNORE, L3_DOLLAR, IGNORE, M },
106 /*0x25*/ { IGNORE, IGNORE, L3_PERCENT, IGNORE, M },
107 /*0x26*/ { IGNORE, IGNORE, L3_AMPERSAND, IGNORE, M },
108 /*0x27*/ { IGNORE, IGNORE, L3_APOSTROPHE, IGNORE, M },
109 /*0x28*/ { IGNORE, IGNORE, L3_L_PARANTHESIS, IGNORE, M },
110 /*0x29*/ { IGNORE, IGNORE, L3_R_PARENTHESIS, IGNORE, M },
111 /*0x2A*/ { IGNORE, IGNORE, L3_ASTERISK, IGNORE, M },
112 /*0x2B*/ { IGNORE, IGNORE, L3_PLUS, IGNORE, M },
113 /*0x2C*/ { IGNORE, IGNORE, L3_COMMA, IGNORE, M },
114 /*0x2D*/ { IGNORE, IGNORE, L3_HYPHEN, IGNORE, M },
115 /*0x2E*/ { IGNORE, IGNORE, L3_FULL_STOP, IGNORE, M },
116 /*0x2F*/ { IGNORE, IGNORE, L3_SOLIDUS, IGNORE, M },
117 /*0x30*/ { L1_08, L2_BLANK, L3_BLANK, L4_BLANK, M },
118 /*0x31*/ { L1_18, L2_BLANK, L3_BLANK, L4_BLANK, M },
119 /*0x32*/ { L1_28, L2_BLANK, L3_BLANK, L4_BLANK, M },
120 /*0x33*/ { L1_38, L2_BLANK, L3_BLANK, L4_BLANK, M },
121 /*0x34*/ { L1_48, L2_BLANK, L3_BLANK, L4_BLANK, M },
122 /*0x35*/ { L1_58, L2_BLANK, L3_BLANK, L4_BLANK, M },
123 /*0x36*/ { L1_68, L2_BLANK, L3_BLANK, L4_BLANK, M },
124 /*0x37*/ { L1_78, L2_BLANK, L3_BLANK, L4_BLANK, M },
125 /*0x38*/ { L1_88, L2_BLANK, L3_BLANK, L4_BLANK, M },
126 /*0x39*/ { L1_98, L2_BLANK, L3_BLANK, L4_BLANK, M },
127 /*0x3A*/ { IGNORE, IGNORE, L3_COLON, IGNORE, M },
128 /*0x3B*/ { IGNORE, IGNORE, L3_SEMICOLON, IGNORE, M },
129 /*0x3C*/ { IGNORE, IGNORE, L3_LESS_THAN, IGNORE, M },
130 /*0x3D*/ { IGNORE, IGNORE, L3_EQUAL, IGNORE, M },
131 /*0x3E*/ { IGNORE, IGNORE, L3_GREATER_THAN, IGNORE, M },
132 /*0x3F*/ { IGNORE, IGNORE, L3_QUESTION, IGNORE, M },
133 /*0x40*/ { IGNORE, IGNORE, L3_AT, IGNORE, M },
134 /*0x41*/ { L1_A8, L2_BLANK, L3_BLANK, L4_CAP, M },
135 /*0x42*/ { L1_B8, L2_BLANK, L3_BLANK, L4_CAP, M },
136 /*0x43*/ { L1_C8, L2_BLANK, L3_BLANK, L4_CAP, M },
137 /*0x44*/ { L1_D8, L2_BLANK, L3_BLANK, L4_CAP, M },
138 /*0x45*/ { L1_E8, L2_BLANK, L3_BLANK, L4_CAP, M },
139 /*0x46*/ { L1_F8, L2_BLANK, L3_BLANK, L4_CAP, M },
140 /*0x47*/ { L1_G8, L2_BLANK, L3_BLANK, L4_CAP, M },
141 /*0x48*/ { L1_H8, L2_BLANK, L3_BLANK, L4_CAP, M },
142 /*0x49*/ { L1_I8, L2_BLANK, L3_BLANK, L4_CAP, M },
143 /*0x4A*/ { L1_J8, L2_BLANK, L3_BLANK, L4_CAP, M },
144 /*0x4B*/ { L1_K8, L2_BLANK, L3_BLANK, L4_CAP, M },
145 /*0x4C*/ { L1_L8, L2_BLANK, L3_BLANK, L4_CAP, M },
146 /*0x4D*/ { L1_M8, L2_BLANK, L3_BLANK, L4_CAP, M },
147 /*0x4E*/ { L1_N8, L2_BLANK, L3_BLANK, L4_CAP, M },
148 /*0x4F*/ { L1_O8, L2_BLANK, L3_BLANK, L4_CAP, M },
149 /*0x50*/ { L1_P8, L2_BLANK, L3_BLANK, L4_CAP, M },
150 /*0x51*/ { L1_Q8, L2_BLANK, L3_BLANK, L4_CAP, M },
151 /*0x52*/ { L1_R8, L2_BLANK, L3_BLANK, L4_CAP, M },
152 /*0x53*/ { L1_S8, L2_BLANK, L3_BLANK, L4_CAP, M },
153 /*0x54*/ { L1_T8, L2_BLANK, L3_BLANK, L4_CAP, M },
154 /*0x55*/ { L1_U8, L2_BLANK, L3_BLANK, L4_CAP, M },
155 /*0x56*/ { L1_V8, L2_BLANK, L3_BLANK, L4_CAP, M },
156 /*0x57*/ { L1_W8, L2_BLANK, L3_BLANK, L4_CAP, M },
157 /*0x58*/ { L1_X8, L2_BLANK, L3_BLANK, L4_CAP, M },
158 /*0x59*/ { L1_Y8, L2_BLANK, L3_BLANK, L4_CAP, M },
159 /*0x5A*/ { L1_Z8, L2_BLANK, L3_BLANK, L4_CAP, M },
160 /*0x5B*/ { IGNORE, IGNORE, L3_L_BRACKET, IGNORE, M },
161 /*0x5C*/ { IGNORE, IGNORE, L3_BK_SOLIDUS, IGNORE, M },
162 /*0x5D*/ { IGNORE, IGNORE, L3_R_BRACKET, IGNORE, M },
163 /*0x5E*/ { IGNORE, IGNORE, L3_CIRCUMFLEX, IGNORE, M },
164 /*0x5F*/ { IGNORE, IGNORE, L3_LOW_LINE, IGNORE, M },
165 /*0x60*/ { IGNORE, IGNORE, L3_GRAVE, IGNORE, M },
166 /*0x61*/ { L1_A8, L2_BLANK, L3_BLANK, L4_MIN, M },
167 /*0x62*/ { L1_B8, L2_BLANK, L3_BLANK, L4_MIN, M },
168 /*0x63*/ { L1_C8, L2_BLANK, L3_BLANK, L4_MIN, M },
169 /*0x64*/ { L1_D8, L2_BLANK, L3_BLANK, L4_MIN, M },
170 /*0x65*/ { L1_E8, L2_BLANK, L3_BLANK, L4_MIN, M },
171 /*0x66*/ { L1_F8, L2_BLANK, L3_BLANK, L4_MIN, M },
172 /*0x67*/ { L1_G8, L2_BLANK, L3_BLANK, L4_MIN, M },
173 /*0x68*/ { L1_H8, L2_BLANK, L3_BLANK, L4_MIN, M },
174 /*0x69*/ { L1_I8, L2_BLANK, L3_BLANK, L4_MIN, M },
175 /*0x6A*/ { L1_J8, L2_BLANK, L3_BLANK, L4_MIN, M },
176 /*0x6B*/ { L1_K8, L2_BLANK, L3_BLANK, L4_MIN, M },
177 /*0x6C*/ { L1_L8, L2_BLANK, L3_BLANK, L4_MIN, M },
178 /*0x6D*/ { L1_M8, L2_BLANK, L3_BLANK, L4_MIN, M },
179 /*0x6E*/ { L1_N8, L2_BLANK, L3_BLANK, L4_MIN, M },
180 /*0x6F*/ { L1_O8, L2_BLANK, L3_BLANK, L4_MIN, M },
181 /*0x70*/ { L1_P8, L2_BLANK, L3_BLANK, L4_MIN, M },
182 /*0x71*/ { L1_Q8, L2_BLANK, L3_BLANK, L4_MIN, M },
183 /*0x72*/ { L1_R8, L2_BLANK, L3_BLANK, L4_MIN, M },
184 /*0x73*/ { L1_S8, L2_BLANK, L3_BLANK, L4_MIN, M },
185 /*0x74*/ { L1_T8, L2_BLANK, L3_BLANK, L4_MIN, M },
186 /*0x75*/ { L1_U8, L2_BLANK, L3_BLANK, L4_MIN, M },
187 /*0x76*/ { L1_V8, L2_BLANK, L3_BLANK, L4_MIN, M },
188 /*0x77*/ { L1_W8, L2_BLANK, L3_BLANK, L4_MIN, M },
189 /*0x78*/ { L1_X8, L2_BLANK, L3_BLANK, L4_MIN, M },
190 /*0x79*/ { L1_Y8, L2_BLANK, L3_BLANK, L4_MIN, M },
191 /*0x7A*/ { L1_Z8, L2_BLANK, L3_BLANK, L4_MIN, M },
192 /*0x7B*/ { IGNORE, IGNORE, L3_L_BRACE, IGNORE, M },
193 /*0x7C*/ { IGNORE, IGNORE, L3_V_LINE, IGNORE, M },
194 /*0x7D*/ { IGNORE, IGNORE, L3_R_BRACE, IGNORE, M },
195 /*0x7E*/ { IGNORE, IGNORE, L3_TILDE, IGNORE, M },
196 /*0x7F*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
197 /*0x80*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
198 /*0x81*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
199 /*0x82*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
200 /*0x83*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
201 /*0x84*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
202 /*0x85*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
203 /*0x86*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
204 /*0x87*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
205 /*0x88*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
206 /*0x89*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
207 /*0x8A*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
208 /*0x8B*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
209 /*0x8C*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
210 /*0x8D*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
211 /*0x8E*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
212 /*0x8F*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
213 /*0x90*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
214 /*0x91*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
215 /*0x92*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
216 /*0x93*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
217 /*0x94*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
218 /*0x95*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
219 /*0x96*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
220 /*0x97*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
221 /*0x98*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
222 /*0x99*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
223 /*0x9A*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
224 /*0x9B*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
225 /*0x9C*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
226 /*0x9D*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
227 /*0x9E*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
228 /*0x9F*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
229 /*0xA0*/ { IGNORE, IGNORE, L3_NB_SACE, IGNORE, X },
230 /*0xA1*/ { L1_KO_KAI, L2_BLANK, L3_BLANK, L4_BLANK, M | _consnt},
231 /*0xA2*/ { L1_KHO_KHAI, L2_BLANK, L3_BLANK, L4_BLANK, M | _consnt},
232 /*0xA3*/ { L1_KHO_KHUAT, L2_BLANK, L3_BLANK, L4_BLANK, M | _consnt},
233 /*0xA4*/ { L1_KHO_KHWAI, L2_BLANK, L3_BLANK, L4_BLANK, M | _consnt},
234 /*0xA5*/ { L1_KHO_KHON, L2_BLANK, L3_BLANK, L4_BLANK, M | _consnt},
235 /*0xA6*/ { L1_KHO_RAKHANG, L2_BLANK, L3_BLANK, L4_BLANK, M | _consnt},
236 /*0xA7*/ { L1_NGO_NGU, L2_BLANK, L3_BLANK, L4_BLANK, M | _consnt},
237 /*0xA8*/ { L1_CHO_CHAN, L2_BLANK, L3_BLANK, L4_BLANK, M | _consnt},
238 /*0xA9*/ { L1_CHO_CHING, L2_BLANK, L3_BLANK, L4_BLANK, M | _consnt},
239 /*0xAA*/ { L1_CHO_CHANG, L2_BLANK, L3_BLANK, L4_BLANK, M | _consnt},
240 /*0xAB*/ { L1_SO_SO, L2_BLANK, L3_BLANK, L4_BLANK, M | _consnt},
241 /*0xAC*/ { L1_CHO_CHOE, L2_BLANK, L3_BLANK, L4_BLANK, M | _consnt},
242 /*0xAD*/ { L1_YO_YING, L2_BLANK, L3_BLANK, L4_BLANK, M | _consnt},
243 /*0xAE*/ { L1_DO_CHADA, L2_BLANK, L3_BLANK, L4_BLANK, M | _consnt},
244 /*0xAF*/ { L1_TO_PATAK, L2_BLANK, L3_BLANK, L4_BLANK, M | _consnt},
245 /*0xB0*/ { L1_THO_THAN, L2_BLANK,L3_BLANK, L4_BLANK, M | _consnt},
246 /*0xB1*/ { L1_THO_NANGMONTHO, L2_BLANK, L3_BLANK, L4_BLANK, M | _consnt},
247 /*0xB2*/ { L1_THO_PHUTHAO, L2_BLANK, L3_BLANK, L4_BLANK, M | _consnt},
248 /*0xB3*/ { L1_NO_NEN, L2_BLANK, L3_BLANK, L4_BLANK, M | _consnt},
249 /*0xB4*/ { L1_DO_DEK, L2_BLANK, L3_BLANK, L4_BLANK, M | _consnt},
250 /*0xB5*/ { L1_TO_TAO, L2_BLANK, L3_BLANK, L4_BLANK, M | _consnt},
251 /*0xB6*/ { L1_THO_THUNG, L2_BLANK, L3_BLANK, L4_BLANK, M | _consnt},
252 /*0xB7*/ { L1_THO_THAHAN, L2_BLANK, L3_BLANK, L4_BLANK, M | _consnt},
253 /*0xB8*/ { L1_THO_THONG, L2_BLANK, L3_BLANK, L4_BLANK, M | _consnt},
254 /*0xB9*/ { L1_NO_NU, L2_BLANK, L3_BLANK, L4_BLANK, M | _consnt},
255 /*0xBA*/ { L1_BO_BAIMAI, L2_BLANK, L3_BLANK, L4_BLANK, M | _consnt},
256 /*0xBB*/ { L1_PO_PLA, L2_BLANK, L3_BLANK, L4_BLANK, M | _consnt},
257 /*0xBC*/ { L1_PHO_PHUNG, L2_BLANK, L3_BLANK, L4_BLANK, M | _consnt},
258 /*0xBD*/ { L1_FO_FA, L2_BLANK, L3_BLANK, L4_BLANK, M | _consnt},
259 /*0xBE*/ { L1_PHO_PHAN, L2_BLANK, L3_BLANK, L4_BLANK, M | _consnt},
260 /*0xBF*/ { L1_FO_FAN, L2_BLANK, L3_BLANK, L4_BLANK, M | _consnt},
261 /*0xC0*/ { L1_PHO_SAMPHAO, L2_BLANK, L3_BLANK, L4_BLANK, M | _consnt},
262 /*0xC1*/ { L1_MO_MA, L2_BLANK, L3_BLANK, L4_BLANK, M | _consnt},
263 /*0xC2*/ { L1_YO_YAK, L2_BLANK, L3_BLANK, L4_BLANK, M | _consnt},
264 /*0xC3*/ { L1_RO_RUA, L2_BLANK, L3_BLANK, L4_BLANK, M | _consnt},
265 /*0xC4*/ { L1_RU, L2_BLANK, L3_BLANK, L4_BLANK, M | _consnt},
266 /*0xC5*/ { L1_LO_LING, L2_BLANK, L3_BLANK, L4_BLANK, M | _consnt},
267 /*0xC6*/ { L1_LU, L2_BLANK, L3_BLANK, L4_BLANK, M | _consnt},
268 /*0xC7*/ { L1_WO_WAEN, L2_BLANK, L3_BLANK, L4_BLANK, M | _consnt},
269 /*0xC8*/ { L1_SO_SALA, L2_BLANK, L3_BLANK, L4_BLANK, M | _consnt},
270 /*0xC9*/ { L1_SO_RUSI, L2_BLANK, L3_BLANK, L4_BLANK, M | _consnt},
271 /*0xCA*/ { L1_SO_SUA, L2_BLANK, L3_BLANK, L4_BLANK, M | _consnt},
272 /*0xCB*/ { L1_HO_HIP, L2_BLANK, L3_BLANK, L4_BLANK, M | _consnt},
273 /*0xCC*/ { L1_LO_CHULA, L2_BLANK, L3_BLANK, L4_BLANK, M | _consnt},
274 /*0xCD*/ { L1_O_ANG, L2_BLANK, L3_BLANK, L4_BLANK, M | _consnt},
275 /*0xCE*/ { L1_HO_NOKHUK, L2_BLANK, L3_BLANK, L4_BLANK, M | _consnt},
276 /*0xCF*/ { IGNORE, IGNORE, L3_PAIYAN_NOI, IGNORE, M},
277 /*0xD0*/ { L1_SARA_A, L2_BLANK, L3_BLANK, L4_BLANK, M | _fllwvowel},
278 /*0xD1*/ { L1_MAI_HAN_AKAT, L2_BLANK, L3_BLANK, L4_BLANK, U | _uprvowel},
279 /*0xD2*/ { L1_SARA_AA, L2_BLANK, L3_BLANK, L4_BLANK, M | _fllwvowel},
280 /*0xD3*/ { L1_SARA_AM, L2_BLANK, L3_BLANK, L4_BLANK, M | _fllwvowel},
281 /*0xD4*/ { L1_SARA_I, L2_BLANK, L3_BLANK, L4_BLANK, U | _uprvowel},
282 /*0xD5*/ { L1_SARA_II, L2_BLANK, L3_BLANK, L4_BLANK, U | _uprvowel},
283 /*0xD6*/ { L1_SARA_UE, L2_BLANK, L3_BLANK, L4_BLANK, U | _uprvowel},
284 /*0xD7*/ { L1_SARA_UEE, L2_BLANK, L3_BLANK, L4_BLANK, U | _uprvowel},
285 /*0xD8*/ { L1_SARA_U, L2_BLANK, L3_BLANK, L4_BLANK, L | _lwrvowel},
286 /*0xD9*/ { L1_SARA_UU, L2_BLANK, L3_BLANK, L4_BLANK, L | _lwrvowel},
287 /*0xDA*/ { IGNORE, L2_PINTHU, L3_BLANK, L4_BLANK, L },
288 /*0xDB*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
289 /*0xDC*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
290 /*0xDD*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
291 /*0xDE*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
292 /*0xDF*/ { IGNORE, IGNORE, L3_BAHT, IGNORE, M},
293 /*0xE0*/ { L1_SARA_E, L2_BLANK, L3_BLANK, L4_BLANK, M | _ldvowel },
294 /*0xE1*/ { L1_SARA_AE, L2_BLANK, L3_BLANK, L4_BLANK, M | _ldvowel },
295 /*0xE2*/ { L1_SARA_O, L2_BLANK, L3_BLANK, L4_BLANK, M | _ldvowel },
296 /*0xE3*/ { L1_SARA_AI_MAIMUAN, L2_BLANK, L3_BLANK, L4_BLANK, M | _ldvowel },
297 /*0xE4*/ { L1_SARA_AI_MAIMALAI, L2_BLANK, L3_BLANK, L4_BLANK, M | _ldvowel },
298 /*0xE5*/ { L1_SARA_AA, L2_BLANK, L3_BLANK, L4_EXT, M | _fllwvowel },
299 /*0xE6*/ { IGNORE, IGNORE, L3_MAI_YAMOK, IGNORE, M | _stone },
300 /*0xE7*/ { IGNORE, L2_TYKHU, L3_BLANK, L4_BLANK, U | _diacrt1 | _stone },
301 /*0xE8*/ { IGNORE, L2_TONE1, L3_BLANK, L4_BLANK, UU | _tone | _combine | _stone },
302 /*0xE9*/ { IGNORE, L2_TONE2, L3_BLANK, L4_BLANK, UU | _tone | _combine | _stone },
303 /*0xEA*/ { IGNORE, L2_TONE3, L3_BLANK, L4_BLANK, UU | _tone | _combine | _stone },
304 /*0xEB*/ { IGNORE, L2_TONE4, L3_BLANK, L4_BLANK, UU | _tone | _combine | _stone },
305 /*0xEC*/ { IGNORE, L2_GARAN, L3_BLANK, L4_BLANK, UU | _diacrt2 | _combine | _stone },
306 /*0xED*/ { L1_NKHIT, L2_BLANK, L3_BLANK, L4_BLANK, U | _diacrt1 },
307 /*0xEE*/ { IGNORE, L2_YAMAK, L3_BLANK, L4_BLANK, U | _diacrt1 },
308 /*0xEF*/ { IGNORE, IGNORE, L3_FONGMAN, IGNORE, M },
309 /*0xF0*/ { L1_08, L2_THAII, L3_BLANK, L4_BLANK, M | _tdig },
310 /*0xF1*/ { L1_18, L2_THAII, L3_BLANK, L4_BLANK, M | _tdig },
311 /*0xF2*/ { L1_28, L2_THAII, L3_BLANK, L4_BLANK, M | _tdig },
312 /*0xF3*/ { L1_38, L2_THAII, L3_BLANK, L4_BLANK, M | _tdig },
313 /*0xF4*/ { L1_48, L2_THAII, L3_BLANK, L4_BLANK, M | _tdig },
314 /*0xF5*/ { L1_58, L2_THAII, L3_BLANK, L4_BLANK, M | _tdig },
315 /*0xF6*/ { L1_68, L2_THAII, L3_BLANK, L4_BLANK, M | _tdig },
316 /*0xF7*/ { L1_78, L2_THAII, L3_BLANK, L4_BLANK, M | _tdig },
317 /*0xF8*/ { L1_88, L2_THAII, L3_BLANK, L4_BLANK, M | _tdig },
318 /*0xF9*/ { L1_98, L2_THAII, L3_BLANK, L4_BLANK, M | _tdig },
319 /*0xFA*/ { IGNORE, IGNORE, L3_ANGKHANKHU, IGNORE, X },
320 /*0xFB*/ { IGNORE, IGNORE, L3_KHOMUT, IGNORE, X },
321 /*0xFC*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
322 /*0xFD*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
323 /*0xFE*/ { IGNORE, IGNORE, IGNORE, IGNORE, X },
324 /* Utilize 0xFF for max_sort_chr in my_like_range_tis620 */
325 /*0xFF*/ { 255 /*IGNORE*/, IGNORE, IGNORE, IGNORE, X },
328 static uchar NEAR ctype_tis620[257] =
330 0, /* For standard library */
331 32,32,32,32,32,32,32,32,32,40,40,40,40,40,32,32,
332 32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
333 72,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
334 132,132,132,132,132,132,132,132,132,132,16,16,16,16,16,16,
335 16,129,129,129,129,129,129,1,1,1,1,1,1,1,1,1,
336 1,1,1,1,1,1,1,1,1,1,1,16,16,16,16,16,
337 16,130,130,130,130,130,130,2,2,2,2,2,2,2,2,2,
338 2,2,2,2,2,2,2,2,2,2,2,16,16,16,16,32,
339 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
340 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
341 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
342 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
343 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
344 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
345 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
346 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
349 static uchar NEAR to_lower_tis620[]=
351 '\000','\001','\002','\003','\004','\005','\006','\007',
352 '\010','\011','\012','\013','\014','\015','\016','\017',
353 '\020','\021','\022','\023','\024','\025','\026','\027',
354 '\030','\031','\032','\033','\034','\035','\036','\037',
355 ' ', '!', '"', '#', '$', '%', '&', '\'',
356 '(', ')', '*', '+', ',', '-', '.', '/',
357 '0', '1', '2', '3', '4', '5', '6', '7',
358 '8', '9', ':', ';', '<', '=', '>', '?',
359 '@', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
360 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
361 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
362 'x', 'y', 'z', '[', '\\', ']', '^', '_',
363 '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
364 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
365 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
366 'x', 'y', 'z', '{', '|', '}', '~', '\177',
367 (uchar) '\200',(uchar) '\201',(uchar) '\202',(uchar) '\203',(uchar) '\204',(uchar) '\205',(uchar) '\206',(uchar) '\207',
368 (uchar) '\210',(uchar) '\211',(uchar) '\212',(uchar) '\213',(uchar) '\214',(uchar) '\215',(uchar) '\216',(uchar) '\217',
369 (uchar) '\220',(uchar) '\221',(uchar) '\222',(uchar) '\223',(uchar) '\224',(uchar) '\225',(uchar) '\226',(uchar) '\227',
370 (uchar) '\230',(uchar) '\231',(uchar) '\232',(uchar) '\233',(uchar) '\234',(uchar) '\235',(uchar) '\236',(uchar) '\237',
371 (uchar) '\240',(uchar) '\241',(uchar) '\242',(uchar) '\243',(uchar) '\244',(uchar) '\245',(uchar) '\246',(uchar) '\247',
372 (uchar) '\250',(uchar) '\251',(uchar) '\252',(uchar) '\253',(uchar) '\254',(uchar) '\255',(uchar) '\256',(uchar) '\257',
373 (uchar) '\260',(uchar) '\261',(uchar) '\262',(uchar) '\263',(uchar) '\264',(uchar) '\265',(uchar) '\266',(uchar) '\267',
374 (uchar) '\270',(uchar) '\271',(uchar) '\272',(uchar) '\273',(uchar) '\274',(uchar) '\275',(uchar) '\276',(uchar) '\277',
375 (uchar) '\300',(uchar) '\301',(uchar) '\302',(uchar) '\303',(uchar) '\304',(uchar) '\305',(uchar) '\306',(uchar) '\307',
376 (uchar) '\310',(uchar) '\311',(uchar) '\312',(uchar) '\313',(uchar) '\314',(uchar) '\315',(uchar) '\316',(uchar) '\317',
377 (uchar) '\320',(uchar) '\321',(uchar) '\322',(uchar) '\323',(uchar) '\324',(uchar) '\325',(uchar) '\326',(uchar) '\327',
378 (uchar) '\330',(uchar) '\331',(uchar) '\332',(uchar) '\333',(uchar) '\334',(uchar) '\335',(uchar) '\336',(uchar) '\337',
379 (uchar) '\340',(uchar) '\341',(uchar) '\342',(uchar) '\343',(uchar) '\344',(uchar) '\345',(uchar) '\346',(uchar) '\347',
380 (uchar) '\350',(uchar) '\351',(uchar) '\352',(uchar) '\353',(uchar) '\354',(uchar) '\355',(uchar) '\356',(uchar) '\357',
381 (uchar) '\360',(uchar) '\361',(uchar) '\362',(uchar) '\363',(uchar) '\364',(uchar) '\365',(uchar) '\366',(uchar) '\367',
382 (uchar) '\370',(uchar) '\371',(uchar) '\372',(uchar) '\373',(uchar) '\374',(uchar) '\375',(uchar) '\376',(uchar) '\377',
385 static uchar NEAR to_upper_tis620[]=
387 '\000','\001','\002','\003','\004','\005','\006','\007',
388 '\010','\011','\012','\013','\014','\015','\016','\017',
389 '\020','\021','\022','\023','\024','\025','\026','\027',
390 '\030','\031','\032','\033','\034','\035','\036','\037',
391 ' ', '!', '"', '#', '$', '%', '&', '\'',
392 '(', ')', '*', '+', ',', '-', '.', '/',
393 '0', '1', '2', '3', '4', '5', '6', '7',
394 '8', '9', ':', ';', '<', '=', '>', '?',
395 '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
396 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
397 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
398 'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
399 '`', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
400 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
401 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
402 'X', 'Y', 'Z', '{', '|', '}', '~', '\177',
403 (uchar) '\200',(uchar) '\201',(uchar) '\202',(uchar) '\203',(uchar) '\204',(uchar) '\205',(uchar) '\206',(uchar) '\207',
404 (uchar) '\210',(uchar) '\211',(uchar) '\212',(uchar) '\213',(uchar) '\214',(uchar) '\215',(uchar) '\216',(uchar) '\217',
405 (uchar) '\220',(uchar) '\221',(uchar) '\222',(uchar) '\223',(uchar) '\224',(uchar) '\225',(uchar) '\226',(uchar) '\227',
406 (uchar) '\230',(uchar) '\231',(uchar) '\232',(uchar) '\233',(uchar) '\234',(uchar) '\235',(uchar) '\236',(uchar) '\237',
407 (uchar) '\240',(uchar) '\241',(uchar) '\242',(uchar) '\243',(uchar) '\244',(uchar) '\245',(uchar) '\246',(uchar) '\247',
408 (uchar) '\250',(uchar) '\251',(uchar) '\252',(uchar) '\253',(uchar) '\254',(uchar) '\255',(uchar) '\256',(uchar) '\257',
409 (uchar) '\260',(uchar) '\261',(uchar) '\262',(uchar) '\263',(uchar) '\264',(uchar) '\265',(uchar) '\266',(uchar) '\267',
410 (uchar) '\270',(uchar) '\271',(uchar) '\272',(uchar) '\273',(uchar) '\274',(uchar) '\275',(uchar) '\276',(uchar) '\277',
411 (uchar) '\300',(uchar) '\301',(uchar) '\302',(uchar) '\303',(uchar) '\304',(uchar) '\305',(uchar) '\306',(uchar) '\307',
412 (uchar) '\310',(uchar) '\311',(uchar) '\312',(uchar) '\313',(uchar) '\314',(uchar) '\315',(uchar) '\316',(uchar) '\317',
413 (uchar) '\320',(uchar) '\321',(uchar) '\322',(uchar) '\323',(uchar) '\324',(uchar) '\325',(uchar) '\326',(uchar) '\327',
414 (uchar) '\330',(uchar) '\331',(uchar) '\332',(uchar) '\333',(uchar) '\334',(uchar) '\335',(uchar) '\336',(uchar) '\337',
415 (uchar) '\340',(uchar) '\341',(uchar) '\342',(uchar) '\343',(uchar) '\344',(uchar) '\345',(uchar) '\346',(uchar) '\347',
416 (uchar) '\350',(uchar) '\351',(uchar) '\352',(uchar) '\353',(uchar) '\354',(uchar) '\355',(uchar) '\356',(uchar) '\357',
417 (uchar) '\360',(uchar) '\361',(uchar) '\362',(uchar) '\363',(uchar) '\364',(uchar) '\365',(uchar) '\366',(uchar) '\367',
418 (uchar) '\370',(uchar) '\371',(uchar) '\372',(uchar) '\373',(uchar) '\374',(uchar) '\375',(uchar) '\376',(uchar) '\377',
421 static uchar NEAR sort_order_tis620[]=
423 '\000','\001','\002','\003','\004','\005','\006','\007',
424 '\010','\011','\012','\013','\014','\015','\016','\017',
425 '\020','\021','\022','\023','\024','\025','\026','\027',
426 '\030','\031','\032','\033','\034','\035','\036','\037',
427 ' ', '!', '"', '#', '$', '%', '&', '\'',
428 '(', ')', '*', '+', ',', '-', '.', '/',
429 '0', '1', '2', '3', '4', '5', '6', '7',
430 '8', '9', ':', ';', '<', '=', '>', '?',
431 '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
432 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
433 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
434 'X', 'Y', 'Z', '\\', ']', '[', '^', '_',
435 'E', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
436 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
437 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
438 'X', 'Y', 'Z', '{', '|', '}', 'Y', '\177',
439 (uchar) '\200',(uchar) '\201',(uchar) '\202',(uchar) '\203',(uchar) '\204',(uchar) '\205',(uchar) '\206',(uchar) '\207',
440 (uchar) '\210',(uchar) '\211',(uchar) '\212',(uchar) '\213',(uchar) '\214',(uchar) '\215',(uchar) '\216',(uchar) '\217',
441 (uchar) '\220',(uchar) '\221',(uchar) '\222',(uchar) '\223',(uchar) '\224',(uchar) '\225',(uchar) '\226',(uchar) '\227',
442 (uchar) '\230',(uchar) '\231',(uchar) '\232',(uchar) '\233',(uchar) '\234',(uchar) '\235',(uchar) '\236',(uchar) '\237',
443 (uchar) '\240',(uchar) '\241',(uchar) '\242',(uchar) '\243',(uchar) '\244',(uchar) '\245',(uchar) '\246',(uchar) '\247',
444 (uchar) '\250',(uchar) '\251',(uchar) '\252',(uchar) '\253',(uchar) '\254',(uchar) '\255',(uchar) '\256',(uchar) '\257',
445 (uchar) '\260',(uchar) '\261',(uchar) '\262',(uchar) '\263',(uchar) '\264',(uchar) '\265',(uchar) '\266',(uchar) '\267',
446 (uchar) '\270',(uchar) '\271',(uchar) '\272',(uchar) '\273',(uchar) '\274',(uchar) '\275',(uchar) '\276',(uchar) '\277',
447 (uchar) '\300',(uchar) '\301',(uchar) '\302',(uchar) '\303',(uchar) '\304',(uchar) '\305',(uchar) '\306',(uchar) '\307',
448 (uchar) '\310',(uchar) '\311',(uchar) '\312',(uchar) '\313',(uchar) '\314',(uchar) '\315',(uchar) '\316',(uchar) '\317',
449 (uchar) '\320',(uchar) '\321',(uchar) '\322',(uchar) '\323',(uchar) '\324',(uchar) '\325',(uchar) '\326',(uchar) '\327',
450 (uchar) '\330',(uchar) '\331',(uchar) '\332',(uchar) '\333',(uchar) '\334',(uchar) '\335',(uchar) '\336',(uchar) '\337',
451 (uchar) '\340',(uchar) '\341',(uchar) '\342',(uchar) '\343',(uchar) '\344',(uchar) '\345',(uchar) '\346',(uchar) '\347',
452 (uchar) '\350',(uchar) '\351',(uchar) '\352',(uchar) '\353',(uchar) '\354',(uchar) '\355',(uchar) '\356',(uchar) '\357',
453 (uchar) '\360',(uchar) '\361',(uchar) '\362',(uchar) '\363',(uchar) '\364',(uchar) '\365',(uchar) '\366',(uchar) '\367',
454 (uchar) '\370',(uchar) '\371',(uchar) '\372',(uchar) '\373',(uchar) '\374',(uchar) '\375',(uchar) '\376',(uchar) '\377',
459 Convert thai string to "Standard C String Function" sortable string
461 SYNOPSIS
462 thai2sortable()
463 tstr String to convert. Does not have to end with \0
464 len Length of tstr
467 static size_t thai2sortable(uchar *tstr, size_t len)
469 uchar *p;
470 int tlen;
471 uchar l2bias;
473 tlen= len;
474 l2bias= 256 - 8;
475 for (p= tstr; tlen > 0; p++, tlen--)
477 uchar c= *p;
479 if (isthai(c))
481 int *t_ctype0= t_ctype[c];
483 if (isconsnt(c))
484 l2bias -= 8;
485 if (isldvowel(c) && tlen != 1 && isconsnt(p[1]))
487 /* simply swap between leading-vowel and consonant */
488 *p= p[1];
489 p[1]= c;
490 tlen--;
491 p++;
492 continue;
495 /* if found level 2 char (L2_GARAN,L2_TONE*,L2_TYKHU) move to last */
496 if (t_ctype0[1] >= L2_GARAN)
499 l2bias use to control position weight of l2char
500 example (*=l2char) XX*X must come before X*XX
502 memmove((char*) p, (char*) (p+1), tlen-1);
503 tstr[len-1]= l2bias + t_ctype0[1]- L2_GARAN +1;
504 p--;
505 continue;
508 else
510 l2bias-= 8;
511 *p= to_lower_tis620[c];
514 return len;
519 strncoll() replacement, compare 2 string, both are converted to sortable
520 string
522 NOTE:
523 We can't cut strings at end \0 as this would break comparision with
524 LIKE characters, where the min range is stored as end \0
526 Arg: 2 Strings and it compare length
527 Ret: strcmp result
530 static
531 int my_strnncoll_tis620(CHARSET_INFO *cs __attribute__((unused)),
532 const uchar *s1, size_t len1,
533 const uchar *s2, size_t len2,
534 my_bool s2_is_prefix)
536 uchar buf[80] ;
537 uchar *tc1, *tc2;
538 int i;
540 if (s2_is_prefix && len1 > len2)
541 len1= len2;
543 tc1= buf;
544 if ((len1 + len2 +2) > (int) sizeof(buf))
545 tc1= (uchar*) my_str_malloc(len1+len2+2);
546 tc2= tc1 + len1+1;
547 memcpy((char*) tc1, (char*) s1, len1);
548 tc1[len1]= 0; /* if length(s1)> len1, need to put 'end of string' */
549 memcpy((char *)tc2, (char *)s2, len2);
550 tc2[len2]= 0; /* put end of string */
551 thai2sortable(tc1, len1);
552 thai2sortable(tc2, len2);
553 i= strcmp((char*)tc1, (char*)tc2);
554 if (tc1 != buf)
555 my_str_free(tc1);
556 return i;
560 static
561 int my_strnncollsp_tis620(CHARSET_INFO * cs __attribute__((unused)),
562 const uchar *a0, size_t a_length,
563 const uchar *b0, size_t b_length,
564 my_bool diff_if_only_endspace_difference)
566 uchar buf[80], *end, *a, *b, *alloced= NULL;
567 size_t length;
568 int res= 0;
570 #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE
571 diff_if_only_endspace_difference= 0;
572 #endif
574 a= buf;
575 if ((a_length + b_length +2) > (int) sizeof(buf))
576 alloced= a= (uchar*) my_str_malloc(a_length+b_length+2);
578 b= a + a_length+1;
579 memcpy((char*) a, (char*) a0, a_length);
580 a[a_length]= 0; /* if length(a0)> len1, need to put 'end of string' */
581 memcpy((char *)b, (char *)b0, b_length);
582 b[b_length]= 0; /* put end of string */
583 a_length= thai2sortable(a, a_length);
584 b_length= thai2sortable(b, b_length);
586 end= a + (length= min(a_length, b_length));
587 while (a < end)
589 if (*a++ != *b++)
591 res= ((int) a[-1] - (int) b[-1]);
592 goto ret;
595 if (a_length != b_length)
597 int swap= 1;
598 if (diff_if_only_endspace_difference)
599 res= 1; /* Assume 'a' is bigger */
601 Check the next not space character of the longer key. If it's < ' ',
602 then it's smaller than the other key.
604 if (a_length < b_length)
606 /* put shorter key in s */
607 a_length= b_length;
608 a= b;
609 swap= -1; /* swap sign of result */
610 res= -res;
612 for (end= a + a_length-length; a < end ; a++)
614 if (*a != ' ')
616 res= (*a < ' ') ? -swap : swap;
617 goto ret;
622 ret:
624 if (alloced)
625 my_str_free(alloced);
626 return res;
631 strnxfrm replacment, convert Thai string to sortable string
633 Arg: Destination buffer, source string, dest length and source length
634 Ret: Conveted string size
637 static
638 size_t my_strnxfrm_tis620(CHARSET_INFO *cs __attribute__((unused)),
639 uchar *dest, size_t len,
640 const uchar *src, size_t srclen)
642 size_t dstlen= len;
643 len= (size_t) (strmake((char*) dest, (char*) src, min(len, srclen)) -
644 (char*) dest);
645 len= thai2sortable(dest, len);
646 if (dstlen > len)
647 bfill(dest + len, dstlen - len, ' ');
648 return dstlen;
652 static unsigned short cs_to_uni[256]={
653 0x0000,0x0001,0x0002,0x0003,0x0004,0x0005,0x0006,0x0007,
654 0x0008,0x0009,0x000A,0x000B,0x000C,0x000D,0x000E,0x000F,
655 0x0010,0x0011,0x0012,0x0013,0x0014,0x0015,0x0016,0x0017,
656 0x0018,0x0019,0x001A,0x001B,0x001C,0x001D,0x001E,0x001F,
657 0x0020,0x0021,0x0022,0x0023,0x0024,0x0025,0x0026,0x0027,
658 0x0028,0x0029,0x002A,0x002B,0x002C,0x002D,0x002E,0x002F,
659 0x0030,0x0031,0x0032,0x0033,0x0034,0x0035,0x0036,0x0037,
660 0x0038,0x0039,0x003A,0x003B,0x003C,0x003D,0x003E,0x003F,
661 0x0040,0x0041,0x0042,0x0043,0x0044,0x0045,0x0046,0x0047,
662 0x0048,0x0049,0x004A,0x004B,0x004C,0x004D,0x004E,0x004F,
663 0x0050,0x0051,0x0052,0x0053,0x0054,0x0055,0x0056,0x0057,
664 0x0058,0x0059,0x005A,0x005B,0x005C,0x005D,0x005E,0x005F,
665 0x0060,0x0061,0x0062,0x0063,0x0064,0x0065,0x0066,0x0067,
666 0x0068,0x0069,0x006A,0x006B,0x006C,0x006D,0x006E,0x006F,
667 0x0070,0x0071,0x0072,0x0073,0x0074,0x0075,0x0076,0x0077,
668 0x0078,0x0079,0x007A,0x007B,0x007C,0x007D,0x007E,0x007F,
669 0x0080,0x0081,0x0082,0x0083,0x0084,0x0085,0x0086,0x0087,
670 0x0088,0x0089,0x008A,0x008B,0x008C,0x008D,0x008E,0x008F,
671 0x0090,0x0091,0x0092,0x0093,0x0094,0x0095,0x0096,0x0097,
672 0x0098,0x0099,0x009A,0x009B,0x009C,0x009D,0x009E,0x009F,
673 0xFFFD,0x0E01,0x0E02,0x0E03,0x0E04,0x0E05,0x0E06,0x0E07,
674 0x0E08,0x0E09,0x0E0A,0x0E0B,0x0E0C,0x0E0D,0x0E0E,0x0E0F,
675 0x0E10,0x0E11,0x0E12,0x0E13,0x0E14,0x0E15,0x0E16,0x0E17,
676 0x0E18,0x0E19,0x0E1A,0x0E1B,0x0E1C,0x0E1D,0x0E1E,0x0E1F,
677 0x0E20,0x0E21,0x0E22,0x0E23,0x0E24,0x0E25,0x0E26,0x0E27,
678 0x0E28,0x0E29,0x0E2A,0x0E2B,0x0E2C,0x0E2D,0x0E2E,0x0E2F,
679 0x0E30,0x0E31,0x0E32,0x0E33,0x0E34,0x0E35,0x0E36,0x0E37,
680 0x0E38,0x0E39,0x0E3A,0xFFFD,0xFFFD,0xFFFD,0xFFFD,0x0E3F,
681 0x0E40,0x0E41,0x0E42,0x0E43,0x0E44,0x0E45,0x0E46,0x0E47,
682 0x0E48,0x0E49,0x0E4A,0x0E4B,0x0E4C,0x0E4D,0x0E4E,0x0E4F,
683 0x0E50,0x0E51,0x0E52,0x0E53,0x0E54,0x0E55,0x0E56,0x0E57,
684 0x0E58,0x0E59,0x0E5A,0x0E5B,0xFFFD,0xFFFD,0xFFFD,0xFFFD
686 static uchar pl00[256]={
687 0x0000,0x0001,0x0002,0x0003,0x0004,0x0005,0x0006,0x0007,
688 0x0008,0x0009,0x000A,0x000B,0x000C,0x000D,0x000E,0x000F,
689 0x0010,0x0011,0x0012,0x0013,0x0014,0x0015,0x0016,0x0017,
690 0x0018,0x0019,0x001A,0x001B,0x001C,0x001D,0x001E,0x001F,
691 0x0020,0x0021,0x0022,0x0023,0x0024,0x0025,0x0026,0x0027,
692 0x0028,0x0029,0x002A,0x002B,0x002C,0x002D,0x002E,0x002F,
693 0x0030,0x0031,0x0032,0x0033,0x0034,0x0035,0x0036,0x0037,
694 0x0038,0x0039,0x003A,0x003B,0x003C,0x003D,0x003E,0x003F,
695 0x0040,0x0041,0x0042,0x0043,0x0044,0x0045,0x0046,0x0047,
696 0x0048,0x0049,0x004A,0x004B,0x004C,0x004D,0x004E,0x004F,
697 0x0050,0x0051,0x0052,0x0053,0x0054,0x0055,0x0056,0x0057,
698 0x0058,0x0059,0x005A,0x005B,0x005C,0x005D,0x005E,0x005F,
699 0x0060,0x0061,0x0062,0x0063,0x0064,0x0065,0x0066,0x0067,
700 0x0068,0x0069,0x006A,0x006B,0x006C,0x006D,0x006E,0x006F,
701 0x0070,0x0071,0x0072,0x0073,0x0074,0x0075,0x0076,0x0077,
702 0x0078,0x0079,0x007A,0x007B,0x007C,0x007D,0x007E,0x007F,
703 0x0080,0x0081,0x0082,0x0083,0x0084,0x0085,0x0086,0x0087,
704 0x0088,0x0089,0x008A,0x008B,0x008C,0x008D,0x008E,0x008F,
705 0x0090,0x0091,0x0092,0x0093,0x0094,0x0095,0x0096,0x0097,
706 0x0098,0x0099,0x009A,0x009B,0x009C,0x009D,0x009E,0x009F,
707 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
708 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
709 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
710 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
711 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
712 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
713 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
714 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
715 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
716 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
717 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
718 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
720 static uchar pl0E[256]={
721 0x0000,0x00A1,0x00A2,0x00A3,0x00A4,0x00A5,0x00A6,0x00A7,
722 0x00A8,0x00A9,0x00AA,0x00AB,0x00AC,0x00AD,0x00AE,0x00AF,
723 0x00B0,0x00B1,0x00B2,0x00B3,0x00B4,0x00B5,0x00B6,0x00B7,
724 0x00B8,0x00B9,0x00BA,0x00BB,0x00BC,0x00BD,0x00BE,0x00BF,
725 0x00C0,0x00C1,0x00C2,0x00C3,0x00C4,0x00C5,0x00C6,0x00C7,
726 0x00C8,0x00C9,0x00CA,0x00CB,0x00CC,0x00CD,0x00CE,0x00CF,
727 0x00D0,0x00D1,0x00D2,0x00D3,0x00D4,0x00D5,0x00D6,0x00D7,
728 0x00D8,0x00D9,0x00DA,0x0000,0x0000,0x0000,0x0000,0x00DF,
729 0x00E0,0x00E1,0x00E2,0x00E3,0x00E4,0x00E5,0x00E6,0x00E7,
730 0x00E8,0x00E9,0x00EA,0x00EB,0x00EC,0x00ED,0x00EE,0x00EF,
731 0x00F0,0x00F1,0x00F2,0x00F3,0x00F4,0x00F5,0x00F6,0x00F7,
732 0x00F8,0x00F9,0x00FA,0x00FB,0x0000,0x0000,0x0000,0x0000,
733 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
734 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
735 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
736 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
737 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
738 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
739 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
740 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
741 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
742 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
743 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
744 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
745 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
746 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
747 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
748 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
749 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
750 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
751 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
752 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
754 static uchar plFF[256]={
755 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
756 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
757 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
758 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
759 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
760 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
761 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
762 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
763 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
764 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
765 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
766 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
767 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
768 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
769 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
770 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
771 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
772 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
773 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
774 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
775 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
776 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
777 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
778 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
779 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
780 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
781 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
782 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
783 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
784 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
785 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
786 0x0000,0x0000,0x0000,0x0000,0x0000,0x00FF,0x0000,0x0000
788 static uchar *uni_to_cs[256]={
789 pl00,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
790 NULL,NULL,NULL,NULL,NULL,NULL,pl0E,NULL,
791 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
792 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
793 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
794 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
795 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
796 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
797 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
798 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
799 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
800 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
801 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
802 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
803 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
804 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
805 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
806 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
807 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
808 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
809 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
810 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
811 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
812 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
813 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
814 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
815 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
816 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
817 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
818 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
819 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
820 NULL,NULL,NULL,NULL,NULL,NULL,NULL,plFF
824 static
825 int my_mb_wc_tis620(CHARSET_INFO *cs __attribute__((unused)),
826 my_wc_t *wc,
827 const uchar *str,
828 const uchar *end __attribute__((unused)))
830 if (str >= end)
831 return MY_CS_TOOSMALL;
833 *wc=cs_to_uni[*str];
834 return (!wc[0] && str[0]) ? -1 : 1;
837 static
838 int my_wc_mb_tis620(CHARSET_INFO *cs __attribute__((unused)),
839 my_wc_t wc,
840 uchar *str,
841 uchar *end __attribute__((unused)))
843 uchar *pl;
845 if (str >= end)
846 return MY_CS_TOOSMALL;
848 pl= uni_to_cs[(wc>>8) & 0xFF];
849 str[0]= pl ? pl[wc & 0xFF] : '\0';
850 return (!str[0] && wc) ? MY_CS_ILUNI : 1;
854 static MY_COLLATION_HANDLER my_collation_ci_handler =
856 NULL, /* init */
857 my_strnncoll_tis620,
858 my_strnncollsp_tis620,
859 my_strnxfrm_tis620,
860 my_strnxfrmlen_simple,
861 my_like_range_simple,
862 my_wildcmp_8bit, /* wildcmp */
863 my_strcasecmp_8bit,
864 my_instr_simple, /* QQ: To be fixed */
865 my_hash_sort_simple,
866 my_propagate_simple
869 static MY_CHARSET_HANDLER my_charset_handler=
871 NULL, /* init */
872 NULL, /* ismbchar */
873 my_mbcharlen_8bit, /* mbcharlen */
874 my_numchars_8bit,
875 my_charpos_8bit,
876 my_well_formed_len_8bit,
877 my_lengthsp_8bit,
878 my_numcells_8bit,
879 my_mb_wc_tis620, /* mb_wc */
880 my_wc_mb_tis620, /* wc_mb */
881 my_mb_ctype_8bit,
882 my_caseup_str_8bit,
883 my_casedn_str_8bit,
884 my_caseup_8bit,
885 my_casedn_8bit,
886 my_snprintf_8bit,
887 my_long10_to_str_8bit,
888 my_longlong10_to_str_8bit,
889 my_fill_8bit,
890 my_strntol_8bit,
891 my_strntoul_8bit,
892 my_strntoll_8bit,
893 my_strntoull_8bit,
894 my_strntod_8bit,
895 my_strtoll10_8bit,
896 my_strntoull10rnd_8bit,
897 my_scan_8bit
902 CHARSET_INFO my_charset_tis620_thai_ci=
904 18,0,0, /* number */
905 MY_CS_COMPILED|MY_CS_PRIMARY|MY_CS_STRNXFRM, /* state */
906 "tis620", /* cs name */
907 "tis620_thai_ci", /* name */
908 "", /* comment */
909 NULL, /* tailoring */
910 ctype_tis620,
911 to_lower_tis620,
912 to_upper_tis620,
913 sort_order_tis620,
914 NULL, /* contractions */
915 NULL, /* sort_order_big*/
916 NULL, /* tab_to_uni */
917 NULL, /* tab_from_uni */
918 my_unicase_default, /* caseinfo */
919 NULL, /* state_map */
920 NULL, /* ident_map */
921 4, /* strxfrm_multiply */
922 1, /* caseup_multiply */
923 1, /* casedn_multiply */
924 1, /* mbminlen */
925 1, /* mbmaxlen */
926 0, /* min_sort_char */
927 255, /* max_sort_char */
928 ' ', /* pad char */
929 0, /* escape_with_backslash_is_dangerous */
930 &my_charset_handler,
931 &my_collation_ci_handler
934 CHARSET_INFO my_charset_tis620_bin=
936 89,0,0, /* number */
937 MY_CS_COMPILED|MY_CS_BINSORT, /* state */
938 "tis620", /* cs name */
939 "tis620_bin", /* name */
940 "", /* comment */
941 NULL, /* tailoring */
942 ctype_tis620,
943 to_lower_tis620,
944 to_upper_tis620,
945 NULL, /* sort_order */
946 NULL, /* contractions */
947 NULL, /* sort_order_big*/
948 NULL, /* tab_to_uni */
949 NULL, /* tab_from_uni */
950 my_unicase_default, /* caseinfo */
951 NULL, /* state_map */
952 NULL, /* ident_map */
953 1, /* strxfrm_multiply */
954 1, /* caseup_multiply */
955 1, /* casedn_multiply */
956 1, /* mbminlen */
957 1, /* mbmaxlen */
958 0, /* min_sort_char */
959 255, /* max_sort_char */
960 ' ', /* pad char */
961 0, /* escape_with_backslash_is_dangerous */
962 &my_charset_handler,
963 &my_collation_8bit_bin_handler
967 #endif