1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 /*
26  * ICU License - ICU 1.8.1 and later
27  *
28  * COPYRIGHT AND PERMISSION NOTICE
29  *
30  * Copyright (c) 1995-2006 International Business Machines Corporation and
31  * others
32  *
33  * All rights reserved.
34  *
35  * Permission is hereby granted, free of charge, to any person obtaining a
36  * copy of this software and associated documentation files (the
37  * "Software"), to deal in the Software without restriction, including
38  * without limitation the rights to use, copy, modify, merge, publish,
39  * distribute, and/or sell copies of the Software, and to permit persons
40  * to whom the Software is furnished to do so, provided that the above
41  * copyright notice(s) and this permission notice appear in all copies of
42  * the Software and that both the above copyright notice(s) and this
43  * permission notice appear in supporting documentation.
44  *
45  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
46  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
47  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
48  * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
49  * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
50  * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
51  * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
52  * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
53  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
54  *
55  * Except as contained in this notice, the name of a copyright holder
56  * shall not be used in advertising or otherwise to promote the sale, use
57  * or other dealings in this Software without prior written authorization
58  * of the copyright holder.
59  *
60  * -----------------------------------------------------------------------------
61  * All trademarks and registered trademarks mentioned herein are the property of
62  * their respective owners.
63  */
64 /*
65  * This file has been modified by Sun Microsystems, Inc.
66  */
67 
68 #ifndef _SYS_KICONV_EMEA2_H
69 #define	_SYS_KICONV_EMEA2_H
70 
71 #ifdef __cplusplus
72 extern "C" {
73 #endif
74 
75 #include <sys/kiconv.h>
76 
77 #ifdef	_KERNEL
78 
79 /*
80  * Mapping tables from CP720 to UTF-8.
81  *
82  * Indices are calculated by subtracting 0x80 from single byte character code
83  * values.
84  *
85  * Each component has up to three UTF-8 character bytes; the first byte will
86  * be used to figure out on how many bytes should be taken. If size figured
87  * out has a value less than zero, that means that component isn't valid and
88  * has no assigned character.
89  *
90  * We only provide mappings that will guarantee exact 1-to-1 roundtrip code
91  * conversions for the maximum compatibility with previous CP720 conversions
92  * in our storage products. (The same also goes to the other table at below.)
93  */
94 static const kiconv_to_utf8_tbl_comp_t cp720_to_u8_tbl[128] = {
95 	{ 0xC2, 0x80, 0x00 },	/* 0x80 */
96 	{ 0xC2, 0x81, 0x00 },	/* 0x81 */
97 	{ 0xC3, 0xA9, 0x00 },	/* 0x82 */
98 	{ 0xC3, 0xA2, 0x00 },	/* 0x83 */
99 	{ 0xC2, 0x84, 0x00 },	/* 0x84 */
100 	{ 0xC3, 0xA0, 0x00 },	/* 0x85 */
101 	{ 0xC2, 0x86, 0x00 },	/* 0x86 */
102 	{ 0xC3, 0xA7, 0x00 },	/* 0x87 */
103 	{ 0xC3, 0xAA, 0x00 },	/* 0x88 */
104 	{ 0xC3, 0xAB, 0x00 },	/* 0x89 */
105 	{ 0xC3, 0xA8, 0x00 },	/* 0x8A */
106 	{ 0xC3, 0xAF, 0x00 },	/* 0x8B */
107 	{ 0xC3, 0xAE, 0x00 },	/* 0x8C */
108 	{ 0xC2, 0x8D, 0x00 },	/* 0x8D */
109 	{ 0xC2, 0x8E, 0x00 },	/* 0x8E */
110 	{ 0xC2, 0x8F, 0x00 },	/* 0x8F */
111 	{ 0xC2, 0x90, 0x00 },	/* 0x90 */
112 	{ 0xD9, 0x91, 0x00 },	/* 0x91 */
113 	{ 0xD9, 0x92, 0x00 },	/* 0x92 */
114 	{ 0xC3, 0xB4, 0x00 },	/* 0x93 */
115 	{ 0xC2, 0xA4, 0x00 },	/* 0x94 */
116 	{ 0xD9, 0x80, 0x00 },	/* 0x95 */
117 	{ 0xC3, 0xBB, 0x00 },	/* 0x96 */
118 	{ 0xC3, 0xB9, 0x00 },	/* 0x97 */
119 	{ 0xD8, 0xA1, 0x00 },	/* 0x98 */
120 	{ 0xD8, 0xA2, 0x00 },	/* 0x99 */
121 	{ 0xD8, 0xA3, 0x00 },	/* 0x9A */
122 	{ 0xD8, 0xA4, 0x00 },	/* 0x9B */
123 	{ 0xC2, 0xA3, 0x00 },	/* 0x9C */
124 	{ 0xD8, 0xA5, 0x00 },	/* 0x9D */
125 	{ 0xD8, 0xA6, 0x00 },	/* 0x9E */
126 	{ 0xD8, 0xA7, 0x00 },	/* 0x9F */
127 	{ 0xD8, 0xA8, 0x00 },	/* 0xA0 */
128 	{ 0xD8, 0xA9, 0x00 },	/* 0xA1 */
129 	{ 0xD8, 0xAA, 0x00 },	/* 0xA2 */
130 	{ 0xD8, 0xAB, 0x00 },	/* 0xA3 */
131 	{ 0xD8, 0xAC, 0x00 },	/* 0xA4 */
132 	{ 0xD8, 0xAD, 0x00 },	/* 0xA5 */
133 	{ 0xD8, 0xAE, 0x00 },	/* 0xA6 */
134 	{ 0xD8, 0xAF, 0x00 },	/* 0xA7 */
135 	{ 0xD8, 0xB0, 0x00 },	/* 0xA8 */
136 	{ 0xD8, 0xB1, 0x00 },	/* 0xA9 */
137 	{ 0xD8, 0xB2, 0x00 },	/* 0xAA */
138 	{ 0xD8, 0xB3, 0x00 },	/* 0xAB */
139 	{ 0xD8, 0xB4, 0x00 },	/* 0xAC */
140 	{ 0xD8, 0xB5, 0x00 },	/* 0xAD */
141 	{ 0xC2, 0xAB, 0x00 },	/* 0xAE */
142 	{ 0xC2, 0xBB, 0x00 },	/* 0xAF */
143 	{ 0xE2, 0x96, 0x91 },	/* 0xB0 */
144 	{ 0xE2, 0x96, 0x92 },	/* 0xB1 */
145 	{ 0xE2, 0x96, 0x93 },	/* 0xB2 */
146 	{ 0xE2, 0x94, 0x82 },	/* 0xB3 */
147 	{ 0xE2, 0x94, 0xA4 },	/* 0xB4 */
148 	{ 0xE2, 0x95, 0xA1 },	/* 0xB5 */
149 	{ 0xE2, 0x95, 0xA2 },	/* 0xB6 */
150 	{ 0xE2, 0x95, 0x96 },	/* 0xB7 */
151 	{ 0xE2, 0x95, 0x95 },	/* 0xB8 */
152 	{ 0xE2, 0x95, 0xA3 },	/* 0xB9 */
153 	{ 0xE2, 0x95, 0x91 },	/* 0xBA */
154 	{ 0xE2, 0x95, 0x97 },	/* 0xBB */
155 	{ 0xE2, 0x95, 0x9D },	/* 0xBC */
156 	{ 0xE2, 0x95, 0x9C },	/* 0xBD */
157 	{ 0xE2, 0x95, 0x9B },	/* 0xBE */
158 	{ 0xE2, 0x94, 0x90 },	/* 0xBF */
159 	{ 0xE2, 0x94, 0x94 },	/* 0xC0 */
160 	{ 0xE2, 0x94, 0xB4 },	/* 0xC1 */
161 	{ 0xE2, 0x94, 0xAC },	/* 0xC2 */
162 	{ 0xE2, 0x94, 0x9C },	/* 0xC3 */
163 	{ 0xE2, 0x94, 0x80 },	/* 0xC4 */
164 	{ 0xE2, 0x94, 0xBC },	/* 0xC5 */
165 	{ 0xE2, 0x95, 0x9E },	/* 0xC6 */
166 	{ 0xE2, 0x95, 0x9F },	/* 0xC7 */
167 	{ 0xE2, 0x95, 0x9A },	/* 0xC8 */
168 	{ 0xE2, 0x95, 0x94 },	/* 0xC9 */
169 	{ 0xE2, 0x95, 0xA9 },	/* 0xCA */
170 	{ 0xE2, 0x95, 0xA6 },	/* 0xCB */
171 	{ 0xE2, 0x95, 0xA0 },	/* 0xCC */
172 	{ 0xE2, 0x95, 0x90 },	/* 0xCD */
173 	{ 0xE2, 0x95, 0xAC },	/* 0xCE */
174 	{ 0xE2, 0x95, 0xA7 },	/* 0xCF */
175 	{ 0xE2, 0x95, 0xA8 },	/* 0xD0 */
176 	{ 0xE2, 0x95, 0xA4 },	/* 0xD1 */
177 	{ 0xE2, 0x95, 0xA5 },	/* 0xD2 */
178 	{ 0xE2, 0x95, 0x99 },	/* 0xD3 */
179 	{ 0xE2, 0x95, 0x98 },	/* 0xD4 */
180 	{ 0xE2, 0x95, 0x92 },	/* 0xD5 */
181 	{ 0xE2, 0x95, 0x93 },	/* 0xD6 */
182 	{ 0xE2, 0x95, 0xAB },	/* 0xD7 */
183 	{ 0xE2, 0x95, 0xAA },	/* 0xD8 */
184 	{ 0xE2, 0x94, 0x98 },	/* 0xD9 */
185 	{ 0xE2, 0x94, 0x8C },	/* 0xDA */
186 	{ 0xE2, 0x96, 0x88 },	/* 0xDB */
187 	{ 0xE2, 0x96, 0x84 },	/* 0xDC */
188 	{ 0xE2, 0x96, 0x8C },	/* 0xDD */
189 	{ 0xE2, 0x96, 0x90 },	/* 0xDE */
190 	{ 0xE2, 0x96, 0x80 },	/* 0xDF */
191 	{ 0xD8, 0xB6, 0x00 },	/* 0xE0 */
192 	{ 0xD8, 0xB7, 0x00 },	/* 0xE1 */
193 	{ 0xD8, 0xB8, 0x00 },	/* 0xE2 */
194 	{ 0xD8, 0xB9, 0x00 },	/* 0xE3 */
195 	{ 0xD8, 0xBA, 0x00 },	/* 0xE4 */
196 	{ 0xD9, 0x81, 0x00 },	/* 0xE5 */
197 	{ 0xC2, 0xB5, 0x00 },	/* 0xE6 */
198 	{ 0xD9, 0x82, 0x00 },	/* 0xE7 */
199 	{ 0xD9, 0x83, 0x00 },	/* 0xE8 */
200 	{ 0xD9, 0x84, 0x00 },	/* 0xE9 */
201 	{ 0xD9, 0x85, 0x00 },	/* 0xEA */
202 	{ 0xD9, 0x86, 0x00 },	/* 0xEB */
203 	{ 0xD9, 0x87, 0x00 },	/* 0xEC */
204 	{ 0xD9, 0x88, 0x00 },	/* 0xED */
205 	{ 0xD9, 0x89, 0x00 },	/* 0xEE */
206 	{ 0xD9, 0x8A, 0x00 },	/* 0xEF */
207 	{ 0xE2, 0x89, 0xA1 },	/* 0xF0 */
208 	{ 0xD9, 0x8B, 0x00 },	/* 0xF1 */
209 	{ 0xD9, 0x8C, 0x00 },	/* 0xF2 */
210 	{ 0xD9, 0x8D, 0x00 },	/* 0xF3 */
211 	{ 0xD9, 0x8E, 0x00 },	/* 0xF4 */
212 	{ 0xD9, 0x8F, 0x00 },	/* 0xF5 */
213 	{ 0xD9, 0x90, 0x00 },	/* 0xF6 */
214 	{ 0xE2, 0x89, 0x88 },	/* 0xF7 */
215 	{ 0xC2, 0xB0, 0x00 },	/* 0xF8 */
216 	{ 0xE2, 0x88, 0x99 },	/* 0xF9 */
217 	{ 0xC2, 0xB7, 0x00 },	/* 0xFA */
218 	{ 0xE2, 0x88, 0x9A },	/* 0xFB */
219 	{ 0xE2, 0x81, 0xBF },	/* 0xFC */
220 	{ 0xC2, 0xB2, 0x00 },	/* 0xFD */
221 	{ 0xE2, 0x96, 0xA0 },	/* 0xFE */
222 	{ 0xC2, 0xA0, 0x00 },	/* 0xFF */
223 };
224 
225 /*
226  * Mapping tables from UTF-8 to CP720.
227  *
228  * The table is sorted with UTF-8 values to be used with binary search.
229  * UTF-8 character byte values are saved at uint32_t:24 contiguously as
230  * scalar values.
231  */
232 static const kiconv_to_sb_tbl_comp_t u8_to_cp720_tbl[128] = {
233 	{ 0x00C280, 0x80 },
234 	{ 0x00C281, 0x81 },
235 	{ 0x00C284, 0x84 },
236 	{ 0x00C286, 0x86 },
237 	{ 0x00C28D, 0x8D },
238 	{ 0x00C28E, 0x8E },
239 	{ 0x00C28F, 0x8F },
240 	{ 0x00C290, 0x90 },
241 	{ 0x00C2A0, 0xFF },
242 	{ 0x00C2A3, 0x9C },
243 	{ 0x00C2A4, 0x94 },
244 	{ 0x00C2AB, 0xAE },
245 	{ 0x00C2B0, 0xF8 },
246 	{ 0x00C2B2, 0xFD },
247 	{ 0x00C2B5, 0xE6 },
248 	{ 0x00C2B7, 0xFA },
249 	{ 0x00C2BB, 0xAF },
250 	{ 0x00C3A0, 0x85 },
251 	{ 0x00C3A2, 0x83 },
252 	{ 0x00C3A7, 0x87 },
253 	{ 0x00C3A8, 0x8A },
254 	{ 0x00C3A9, 0x82 },
255 	{ 0x00C3AA, 0x88 },
256 	{ 0x00C3AB, 0x89 },
257 	{ 0x00C3AE, 0x8C },
258 	{ 0x00C3AF, 0x8B },
259 	{ 0x00C3B4, 0x93 },
260 	{ 0x00C3B9, 0x97 },
261 	{ 0x00C3BB, 0x96 },
262 	{ 0x00D8A1, 0x98 },
263 	{ 0x00D8A2, 0x99 },
264 	{ 0x00D8A3, 0x9A },
265 	{ 0x00D8A4, 0x9B },
266 	{ 0x00D8A5, 0x9D },
267 	{ 0x00D8A6, 0x9E },
268 	{ 0x00D8A7, 0x9F },
269 	{ 0x00D8A8, 0xA0 },
270 	{ 0x00D8A9, 0xA1 },
271 	{ 0x00D8AA, 0xA2 },
272 	{ 0x00D8AB, 0xA3 },
273 	{ 0x00D8AC, 0xA4 },
274 	{ 0x00D8AD, 0xA5 },
275 	{ 0x00D8AE, 0xA6 },
276 	{ 0x00D8AF, 0xA7 },
277 	{ 0x00D8B0, 0xA8 },
278 	{ 0x00D8B1, 0xA9 },
279 	{ 0x00D8B2, 0xAA },
280 	{ 0x00D8B3, 0xAB },
281 	{ 0x00D8B4, 0xAC },
282 	{ 0x00D8B5, 0xAD },
283 	{ 0x00D8B6, 0xE0 },
284 	{ 0x00D8B7, 0xE1 },
285 	{ 0x00D8B8, 0xE2 },
286 	{ 0x00D8B9, 0xE3 },
287 	{ 0x00D8BA, 0xE4 },
288 	{ 0x00D980, 0x95 },
289 	{ 0x00D981, 0xE5 },
290 	{ 0x00D982, 0xE7 },
291 	{ 0x00D983, 0xE8 },
292 	{ 0x00D984, 0xE9 },
293 	{ 0x00D985, 0xEA },
294 	{ 0x00D986, 0xEB },
295 	{ 0x00D987, 0xEC },
296 	{ 0x00D988, 0xED },
297 	{ 0x00D989, 0xEE },
298 	{ 0x00D98A, 0xEF },
299 	{ 0x00D98B, 0xF1 },
300 	{ 0x00D98C, 0xF2 },
301 	{ 0x00D98D, 0xF3 },
302 	{ 0x00D98E, 0xF4 },
303 	{ 0x00D98F, 0xF5 },
304 	{ 0x00D990, 0xF6 },
305 	{ 0x00D991, 0x91 },
306 	{ 0x00D992, 0x92 },
307 	{ 0xE281BF, 0xFC },
308 	{ 0xE28899, 0xF9 },
309 	{ 0xE2889A, 0xFB },
310 	{ 0xE28988, 0xF7 },
311 	{ 0xE289A1, 0xF0 },
312 	{ 0xE29480, 0xC4 },
313 	{ 0xE29482, 0xB3 },
314 	{ 0xE2948C, 0xDA },
315 	{ 0xE29490, 0xBF },
316 	{ 0xE29494, 0xC0 },
317 	{ 0xE29498, 0xD9 },
318 	{ 0xE2949C, 0xC3 },
319 	{ 0xE294A4, 0xB4 },
320 	{ 0xE294AC, 0xC2 },
321 	{ 0xE294B4, 0xC1 },
322 	{ 0xE294BC, 0xC5 },
323 	{ 0xE29590, 0xCD },
324 	{ 0xE29591, 0xBA },
325 	{ 0xE29592, 0xD5 },
326 	{ 0xE29593, 0xD6 },
327 	{ 0xE29594, 0xC9 },
328 	{ 0xE29595, 0xB8 },
329 	{ 0xE29596, 0xB7 },
330 	{ 0xE29597, 0xBB },
331 	{ 0xE29598, 0xD4 },
332 	{ 0xE29599, 0xD3 },
333 	{ 0xE2959A, 0xC8 },
334 	{ 0xE2959B, 0xBE },
335 	{ 0xE2959C, 0xBD },
336 	{ 0xE2959D, 0xBC },
337 	{ 0xE2959E, 0xC6 },
338 	{ 0xE2959F, 0xC7 },
339 	{ 0xE295A0, 0xCC },
340 	{ 0xE295A1, 0xB5 },
341 	{ 0xE295A2, 0xB6 },
342 	{ 0xE295A3, 0xB9 },
343 	{ 0xE295A4, 0xD1 },
344 	{ 0xE295A5, 0xD2 },
345 	{ 0xE295A6, 0xCB },
346 	{ 0xE295A7, 0xCF },
347 	{ 0xE295A8, 0xD0 },
348 	{ 0xE295A9, 0xCA },
349 	{ 0xE295AA, 0xD8 },
350 	{ 0xE295AB, 0xD7 },
351 	{ 0xE295AC, 0xCE },
352 	{ 0xE29680, 0xDF },
353 	{ 0xE29684, 0xDC },
354 	{ 0xE29688, 0xDB },
355 	{ 0xE2968C, 0xDD },
356 	{ 0xE29690, 0xDE },
357 	{ 0xE29691, 0xB0 },
358 	{ 0xE29692, 0xB1 },
359 	{ 0xE29693, 0xB2 },
360 	{ 0xE296A0, 0xFE },
361 };
362 
363 #endif	/* _KERNEL */
364 
365 #ifdef __cplusplus
366 }
367 #endif
368 
369 #endif /* _SYS_KICONV_EMEA2_H */
370