xref: /illumos-gate/usr/src/lib/iconv_modules/ja/common/japanese.h (revision 66582b606a8194f7f3ba5b3a3a6dca5b0d346361)
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 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 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 AND PERMISSION NOTICE
23  *
24  * Copyright (c) 1991-2005 Unicode, Inc. All rights reserved. Distributed
25  * under the Terms of Use in http://www.unicode.org/copyright.html.
26  *
27  * This file has been modified by Sun Microsystems, Inc.
28  */
29 /*
30  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
31  * Use is subject to license terms.
32  */
33 
34 
35 #define GET(c)		((c) = *ip, ip++, ileft--)
36 #define PUT(c)		(*op = (c), op++, oleft--)
37 #define UNGET()		(ip--, ileft++)
38 
39 #if	defined(DEBUG)
40 #include <stdio.h>
41 static const char	*debugmsg = "<empty>";
42 #define	DEBUGMSG(msg)	debugmsg = (msg);
43 #else	/* ! DEBUG */
44 #define	DEBUGMSG(msg)	;
45 #endif	/* DEBUG */
46 
47 #define	RETERROR(no, msg) {\
48 		errno = (no);\
49 		DEBUGMSG(msg);\
50 		rv = ((size_t)-1);\
51 		goto ret;\
52 	}
53 
54 #if	defined(DEBUG)
55 #define	DEBUGPRINTERROR \
56 	if (rv == (size_t)-1) { \
57 		if (errno == EILSEQ) { \
58 			fprintf(stderr, "DEBUG: EILSEQ: %s\n", debugmsg); \
59 		} else if (errno == E2BIG) { \
60 			fprintf(stderr, "DEBUG: E2BIG: %s\n", debugmsg); \
61 		} else if (errno == EINVAL) { \
62 			fprintf(stderr, "DEBUG: EINVAL: %s\n", debugmsg); \
63 		} else { \
64 			fprintf(stderr, \
65 			"DEBUG: errno=%d: %s\n", errno, debugmsg); \
66 		} \
67 	}
68 #else	/* !DEBUG */
69 #define	DEBUGPRINTERROR	/* nop */
70 #endif	/* DEBUG */
71 
72 #define NGET(c, msg) \
73 	if (ileft-- == 0) {\
74 		RETERROR(EINVAL, msg)\
75 	} else {\
76 		(c) = *ip++;\
77 	}
78 
79 #define NPUT(c, msg) \
80 	if (oleft-- == 0) {\
81 		RETERROR(E2BIG, msg)\
82 	} else {\
83 		*op++ = (c);\
84 	}
85 
86 /* to be obsoleted; migrate to PUTU() in jfp_iconv_unicode.h */
87 #if	defined(JFP_ICONV_TOCODE_UCS2)
88 #define	PUTUCS2(uni, msg)	\
89 	if (write_unicode((unsigned int)uni, &op, &oleft, little, msg) \
90 			== (size_t)-1) { \
91 		rv = ((size_t)-1);\
92 		goto ret; \
93 	}
94 #else	/* !JFP_ICONV_TOCODE_UCS2 */
95 #define	PUTUCS2(ucs2, msg)	\
96 	if (ucs2 <= 0x7f) {\
97 		NPUT((unsigned char)(ucs2), msg);\
98 	} else if (ucs2 <= 0x7ff) {\
99 		NPUT((unsigned char)((((ucs2)>>6) & 0x1f) | 0xc0), msg);\
100 		NPUT((unsigned char)((((ucs2)>>0) & 0x3f) | 0x80), msg);\
101 	} else {\
102 		NPUT((unsigned char)((((ucs2)>>12) & 0x0f) | 0xe0), msg);\
103 		NPUT((unsigned char)((((ucs2)>>6) & 0x3f) | 0x80), msg);\
104 		NPUT((unsigned char)((((ucs2)>>0) & 0x3f) | 0x80), msg);\
105 	}
106 #endif	/* JFP_ICONV_TOCODE_UCS2 */
107 
108 #if	defined(JFP_ICONV_STATELESS)
109 
110 #include	<stdlib.h>
111 
112 static void *
113 _icv_open_stateless(void)
114 {
115 	void	*cd;
116 
117 	/*
118 	 * Do malloc() only to get address as unique conversion descriptor.
119 	 * Though iconv() specification doesn't describe the uniqueness,
120 	 * some existing applications may be assuming it.
121 	 * Unless call of malloc() here is raised as a problem, keep away
122 	 * from breaking the assumption.
123 	 */
124 
125 	if ((cd = malloc((size_t)1)) == NULL) {
126 		errno = ENOMEM;
127 		return ((void *)-1);
128 	} else {
129 		return (cd);
130 	}
131 }
132 
133 static void
134 _icv_close_stateless(void *cd)
135 {
136 	if (cd == NULL) {
137 		errno = EBADF;
138 	} else {
139 		free(cd);
140 	}
141 	return;
142 }
143 
144 #endif	/* ! JFP_ICONV_STATELESS */
145 
146 #define ERR_RETURN	(-1)		/* result code on error */
147 
148 /*
149  * ISXXXX(c) macros below assume (c) is of type unsigned char
150  */
151 /* is a valid code as ascii? */
152 #define ISASC(c)		((c) <= 0x7f)
153 
154 /* is a valid code as C1 control? */
155 #define ISC1CTRL(c)		(((c) >= 0x80) && ((c) <= 0x9f))
156 
157 /* is a valid code as C1 control allowed in EUC? */
158 #define ISC1CTRLEUC(c)		((((c) >= 0x80) && ((c) <= 0x8d)) ||\
159 					(((c) >= 0x90) && ((c) <= 0x9f)))
160 
161 /* is a valid 1st or 2nd byte of EUC codeset 1? */
162 #define ISCS1(c)		(((c) >= 0xa1) && ((c) <= 0xfe))
163 
164 /* is a valid 1st byte of EUC codeset 1 and in range row 1 thru 84? */
165 #define ISCS1_0208(c)		(((c) >= 0xa1) && ((c) <= 0xf4))
166 
167 /* is a valid 1st byte of UDC area in EUC codeset 1? */
168 #define ISCS1_UDC(c)		(((c) >= 0xf5) && ((c) <= 0xfe))
169 
170 /* is a valid 2nd (1st byte is SS2) byte of EUC codeset 2? */
171 #define ISCS2(c)		(((c) >= 0xa1) && ((c) <= 0xdf))
172 
173 /* is a valid 2nd or 3rd (1st byte is SS3) byte of EUC codeset 3? */
174 #define ISCS3(c)		(((c) >= 0xa1) && ((c) <= 0xfe))
175 
176 /* is a valid 2nd (1st byte is SS3) byte of UDC area in EUC codeset 3? */
177 #define ISCS3_UDC(c)		(((c) >= 0xf5) && ((c) <= 0xfe))
178 
179 /* is a valid hankaku_katakana for SJIS? */
180 #define ISSJKANA(c)		(((c) >= 0xa1) && ((c) <= 0xdf))
181 
182 /* is a valid character for the first byte of SJIS multibyte? */
183 #define ISSJMB_1(c)	((((c) >= 0x81) && ((c) <= 0x9f)) ||\
184 				 (((c) >= 0xe0) && ((c) <= 0xfc)))
185 
186 /* is a valid character for the first byte of SJIS kanji? */
187 #define ISSJKANJI1(c)	((((c) >= 0x81) && ((c) <= 0x9f)) ||\
188 				 (((c) >= 0xe0) && ((c) <= 0xea)) ||\
189 				 (((c) >= 0xf0) && ((c) <= 0xf4)))
190 
191 /* is a valid character for the first byte of a part of Suppl. SJIS? */
192 #define ISSJSUPKANJI1(c)	(((c) >= 0xf5) && ((c) <= 0xf9))
193 
194 /* is a valid character for the first byte of SJIS UDC? */
195 #define ISSJUDC_1(c)		(((c) >= 0xf0) && ((c) <= 0xf9))
196 
197 /* is a valid character for the first byte of ibm character set */
198 #define	ISSJIBM(c)		(((c) >= 0xfa) && ((c) <= 0xfc))
199 
200 /* is a valid character for the first byte of ibm character set */
201 #define	ISSJNECIBM(c)		(((c) >= 0xed) && ((c) <= 0xef))
202 
203 /* is a valid character for the second byte of SJIS kanji? */
204 #define ISSJKANJI2(c)	((((c) >= 0x40) && ((c) <= 0x7e)) ||\
205 					 (((c) >= 0x80) && ((c) <= 0xfc)))
206 
207 /* is a valid character for UTF8 UDC ? */
208 #define ISUTF8UDC(c)	(((c) >= 0xe000) && ((c) <= 0xf8ff))
209 
210 #define CS_0			0		/* codeset 0 */
211 #define CS_1			1		/* codeset 1 */
212 #define CS_2			2		/* codeset 2 */
213 #define CS_3			3		/* codeset 3 */
214 
215 #define ST_INIT			0		/* init */
216 #define ST_INCS1		1		/* in codeset 1 */
217 #define ST_INCS2		2		/* in codeset 2 */
218 #define ST_INCS3		3		/* in codeset 3 */
219 #define ST_ESC			4		/* in ESC */
220 #define ST_MBTOG0_1		5		/* in the designation of MB to G0 - 1 */
221 #define ST_MBTOG0_2		6		/* in the designation of MB to G0 - 2 */
222 #define ST_SBTOG0		7		/* in the designation of SB to G0 */
223 #define ST_208REV_1		8		/* in the designation of JISX208-1990 */
224 #define ST_208REV_2		9		/* in the designation of JISX208-1990 */
225 #define ST_REV_AFT_ESC		10		/* in the designation of JISX208-1990 */
226 #define ST_REV_AFT_MBTOG0_1	11		/* in the designation of JISX208-1990 */
227 #define ST_REV_AFT_MBTOG0_2	12		/* in the designation of JISX208-1990 */
228 
229 /*
230  * CODE SET 0
231  * ESC ( B   			: To ASCII
232  * ESC ( J			: To JIS X 0201 - 1976 ROMAN
233  * ESC ( @			: TO ISO 646 IRV
234  *
235  * CODE SET 1
236  * ESC & @ ESC $ ( B		: To JIS X 0208 - 1990
237  * ESC $ ( B			: To JIS X 0208 - 1983/1990
238  * ESC $ ( @			: To JIS X 0208 - 1978
239  * ESC $ B			: To JIS X 0208 - 1983/1990
240  * ESC $ @			: To JIS X 0208 - 1978
241  * ESC & @ ESC $ B		: To JIS X 0208 - 1983/1990
242  *
243  * CODE SET 2
244  * SO  					: G1 -> G
245  * SI  					: G0 -> G
246  * ESC ( I				: To JIS X 0201 - 1976 Katakana
247  *
248  * CODE SET 3
249  * ESC $ ( D			: To JIS X 0212 - 1990
250  * ESC $ D			: To JIS X 0212 - 1990
251  *
252  */
253 
254 #define ESC				0x1b		/* Escape : 1/12 */
255 #define SO				0x0e		/* Shift Out : 0/14 */
256 #define SI				0x0f		/* Shift In  : 0/15 */
257 
258 #define SBTOG0_1			0x28		/* ( : 2/8 */
259 #define F_ASCII				0x42		/* B : 4/2 */
260 #define F_X0201_RM			0x4a		/* J : 4/10 */
261 #define F_ISO646			0x40		/* @ : 4/0 */
262 #define F_X0201_KN			0x49		/* I : 4/9 */
263 
264 #define MBTOG0_1			0x24		/* $ : 2/4 */
265 #define MBTOG0_2			0x28		/* ( : 2/8 */
266 #define F_X0208_83_90			0x42		/* B : 4/2 */
267 #define F_X0208_78			0x40		/* @ : 4/0 */
268 #define F_X0212_90			0x44		/* D : 4/4 */
269 #define	X208REV_1			0x26		/* & : 2/6 */
270 #define	X208REV_2			0x40		/* @ : 4/0 */
271 
272 #define	CMASK				0x7f
273 #define	CMSB				0x80
274 
275 /* the byte length of ESC sequences */
276 #define SEQ_SBTOG0			3			/* ESC + ( + F */
277 #define SEQ_MBTOG0			4			/* ESC + $ + ( + F */
278 #define SEQ_MBTOG0_O			3			/* ESC + $ + F */
279 
280 /* the byte length of SO/SI */
281 #define SEQ_SOSI			1			/* SO or SI */
282 
283 /* the byte length of SS2/SS3 */
284 #define SEQ_SS				1			/* SS2 or SS3 */
285 
286 /* the byte length of JIS characters */
287 #define JISW0				1			/* ASCII */
288 #define JISW1				2			/* Kanji */
289 #define JISW2				1			/* Hankaku Katakana */
290 #define JISW3				2			/* Hojo Kanji */
291 
292 /* the byte length of EUC characters */
293 #define EUCW0				1			/* ASCII */
294 #define EUCW1				2			/* Kanji */
295 #define EUCW2				1			/* Hankaku Katakana */
296 #define EUCW3				2			/* Hojo Kanji */
297 #define SS2W				1			/* SS2 */
298 #define SS3W				1			/* SS3 */
299 
300 /* the byte length of SJIS characters */
301 #define SJISW0				1			/* ASCII */
302 #define SJISW1				2			/* Kanji/UDC */
303 #define SJISW2				1			/* Hankaku Katakana */
304 
305 #define EBCDIC0				1
306 #define EBCDIC1				2
307 #define EBCDIC2				1
308 #define EBCDIC3				2
309 
310 /* the byte length of unknown characters */
311 #define UNKNOWNW			1
312 
313 #define	TRUE	(1)
314 #define	FALSE	(0)
315 
316 /*
317  * sjtojis1[]:
318  * Directly convert 1st octet of Shift-JIS encoded 2bytes codes
319  * to the 1st octet of 7bit-JIS encoded 2bytes codes.
320  * Because the 8th bit is always ON, the size of this array
321  * can be limited to 128. (Precisely, 1st octet can vary between
322  * 0x81 and 0xfc, and correspondent 7bit-JIS value is between
323  * 0x21 and 0x7e. So we can use "0xff" as indicating invalid value.)
324  *
325  * Principal:
326  * 1: Subtract 0x80
327  * 2: Index the array by using the value above as index number.
328  * 3: Value "0xff" means the index number is invalid or, there's
329  *    no 7bit-JIS value that corresponds to.
330  *
331  * Note:
332  * 1: When the 2nd octet of Shift-JIS encoded 2bytes codes is
333  *    more than 0x9f, indexed value should be augumented by 1.
334  * 2: Some of Shift-JIS code points are mapped to JISX0208 plane
335  *    and others are JISX0212 plane.
336  *    Need to differentiate them before indexing and designate
337  *    appropriate character set. This table converts only code points
338  *    within each character set.
339  *
340  */
341 static const unsigned char sjtojis1[] = {
342 /* Values never be indexed */
343 0xff,
344 /* Index 1KU - 62KU in JISX0208 */
345 0x21, 0x23, 0x25, 0x27, 0x29, 0x2b, 0x2d, 0x2f,
346 0x31, 0x33, 0x35, 0x37, 0x39, 0x3b, 0x3d, 0x3f,
347 0x41, 0x43, 0x45, 0x47, 0x49, 0x4b, 0x4d, 0x4f,
348 0x51, 0x53, 0x55, 0x57, 0x59, 0x5b, 0x5d,
349 /* Values never be indexed */
350 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
351 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
352 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
353 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
354 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
355 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
356 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
357 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
358 /* Index 63KU - 84KU in JISX0208 */
359                                           0x5f,
360 0x61, 0x63, 0x65, 0x67, 0x69, 0x6b, 0x6d, 0x6f,
361 0x71, 0x73,
362 /* Values never be indexed */
363 0xff, 0xff,
364 /* Followings will be mapped to 79KU - 84KU in JISX0212 (NEC/IBM) */
365 /* 0x6f, 0x71, 0x73,						*/
366 0xff, 0xff, 0xff,
367 /* Followings will be mapped to 85KU - 94KU in JISX0208 (UDC) */
368 0x75, 0x77, 0x79, 0x7b, 0x7d,
369 /* Followings will be mapped to 85KU - 94KU in JISX0212 (UDC) */
370 0x75, 0x77, 0x79, 0x7b, 0x7d,
371 /* Followings will be mapped to 79KU - 84KU in JISX0212 (IBM) */
372 /* 0x6f, 0x71, 0x73,						*/
373 0xff, 0xff, 0xff,
374 /* Values never be indexed */
375 0xff, 0xff, 0xff
376 };
377 
378 /*
379  * sjtojis2[]:
380  * Directly convert 2nd octet of Shift-JIS encoded 2bytes codes
381  * to the 2nd octet of 7bit-JIS encoded 2bytes codes.
382  * 2nd octet in Shift-JIS can vary between 0x40 and 0xfc(except 0x7f)
383  * and the correspondent 7bit-JIS octet is between 0x21 and 0x7e.
384  * (So we can use '0xff' as indicating invalid value.)
385  *
386  * Principal:
387  * 1: Index the array by using the value above as index number.
388  * 2: Value "0xff" means the index number is invalid or, there's
389  *    no 7bit-JIS value that corresponds to.
390  *
391  * Note:
392  * 1: Some of Shift-JIS code points are mapped to JISX0208 plane
393  *    and others to JISX0212 plane.
394  *    Need to differentiate them before indexing and designate
395  *    appropriate character set. This table converts only code points
396  *    within each character set.
397  *
398  */
399 static const unsigned char sjtojis2[] = {
400 /* Values never be indexed */
401 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
402 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
403 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
404 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
405 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
406 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
407 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
408 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
409 /* Followings are 2nd octet for 'odd' KU */
410 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
411 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30,
412 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
413 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40,
414 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
415 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
416 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
417 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
418 /* Values never be indexed */
419 0xff,
420 /* Followings are 2nd octet for 'odd' KU */
421                                           0x60,
422 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
423 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70,
424 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
425 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e,
426 /* Followings are 2nd octet for 'even' KU */
427 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
428 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30,
429 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
430 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40,
431 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
432 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
433 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
434 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60,
435 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
436 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70,
437 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
438 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e,
439 /* Values never be indexed */
440 0xff, 0xff, 0xff
441 };
442 
443 /*
444  * sjtoibmext[]:
445  * Directly convert Shift-JIS encoded 2bytes codes
446  * to the EUC encoded 2bytes codes.
447  * This table is used for "IBM Extended Character Set" only.
448  *
449  * Principal:
450  * 1: Subtract 0xfa40.
451  * 2: Index the array by using the value above as index number.
452  * 3: Value "0xffff" means the index number is invalid or, there's
453  *    no EUC value that corresponds to.
454  *
455  * Note: The SJIS code points, 0xfa54 and 0xfa5b are mapped to JIS208
456  *       hence they are NOT mapped with tables below.
457  *       (They are mapped to 0xa2cc and 0xa2e8 in JIS208 respectively.)
458  */
459 static const unsigned short sjtoibmext[] = {
460 0xf3f3, 0xf3f4, 0xf3f5, 0xf3f6, 0xf3f7, 0xf3f8, 0xf3f9, 0xf3fa, /* 0xfa47 */
461 0xf3fb, 0xf3fc, 0xf3fd, 0xf3fe, 0xf4a1, 0xf4a2, 0xf4a3, 0xf4a4,
462 0xf4a5, 0xf4a6, 0xf4a7, 0xf4a8, 0xffff, 0xa2c3, 0xf4a9, 0xf4aa,
463 0xf4ab, 0xf4ac, 0xf4ad, 0xffff, 0xd4e3, 0xdcdf, 0xe4e9, 0xe3f8,
464 0xd9a1, 0xb1bb, 0xf4ae, 0xc2ad, 0xc3fc, 0xe4d0, 0xc2bf, 0xbcf4,
465 0xb0a9, 0xb0c8, 0xf4af, 0xb0d2, 0xb0d4, 0xb0e3, 0xb0ee, 0xb1a7,
466 0xb1a3, 0xb1ac, 0xb1a9, 0xb1be, 0xb1df, 0xb1d8, 0xb1c8, 0xb1d7,
467 0xb1e3, 0xb1f4, 0xb1e1, 0xb2a3, 0xf4b0, 0xb2bb, 0xb2e6, 0xffff,
468 0xb2ed, 0xb2f5, 0xb2fc, 0xf4b1, 0xb3b5, 0xb3d8, 0xb3db, 0xb3e5,
469 0xb3ee, 0xb3fb, 0xf4b2, 0xf4b3, 0xb4c0, 0xb4c7, 0xb4d0, 0xb4de,
470 0xf4b4, 0xb5aa, 0xf4b5, 0xb5af, 0xb5c4, 0xb5e8, 0xf4b6, 0xb7c2,
471 0xb7e4, 0xb7e8, 0xb7e7, 0xf4b7, 0xf4b8, 0xf4b9, 0xb8ce, 0xb8e1,
472 0xb8f5, 0xb8f7, 0xb8f8, 0xb8fc, 0xb9af, 0xb9b7, 0xbabe, 0xbadb,
473 0xcdaa, 0xbae1, 0xf4ba, 0xbaeb, 0xbbb3, 0xbbb8, 0xf4bb, 0xbbca,
474 0xf4bc, 0xf4bd, 0xbbd0, 0xbbde, 0xbbf4, 0xbbf5, 0xbbf9, 0xbce4,
475 0xbced, 0xbcfe, 0xf4be, 0xbdc2, 0xbde7, 0xf4bf, 0xbdf0, 0xbeb0,
476 0xbeac, 0xf4c0, 0xbeb3, 0xbebd, 0xbecd, 0xbec9, 0xbee4, 0xbfa8,
477 0xbfc9, 0xc0c4, 0xc0e4, 0xc0f4, 0xc1a6, 0xf4c1, 0xc1f5, 0xc1fc,
478 0xf4c2, 0xc1f8, 0xc2ab, 0xc2a1, 0xc2a5, 0xf4c3, 0xc2b8, 0xc2ba,
479 0xf4c4, 0xc2c4, 0xc2d2, 0xc2d7, 0xc2db, 0xc2de, 0xc2ed, 0xc2f0,
480 0xf4c5, 0xc3a1, 0xc3b5, 0xc3c9, 0xc3b9, 0xf4c6, 0xc3d8, 0xc3fe,
481 0xf4c7, 0xc4cc, 0xf4c8, 0xc4d9, 0xc4ea, 0xc4fd, 0xf4c9, 0xc5a7,
482 0xc5b5, 0xc5b6, 0xf4ca, 0xc5d5, 0xc6b8, 0xc6d7, 0xc6e0, 0xc6ea,
483 0xc6e3, 0xc7a1, 0xc7ab, 0xc7c7, 0xc7c3, 0xffff, 0xffff, 0xffff,
484 0xc7cb, 0xc7cf, 0xc7d9, 0xf4cb, 0xf4cc, 0xc7e6, 0xc7ee, 0xc7fc, /* 0xfb47 */
485 0xc7eb, 0xc7f0, 0xc8b1, 0xc8e5, 0xc8f8, 0xc9a6, 0xc9ab, 0xc9ad,
486 0xf4cd, 0xc9ca, 0xc9d3, 0xc9e9, 0xc9e3, 0xc9fc, 0xc9f4, 0xc9f5,
487 0xf4ce, 0xcab3, 0xcabd, 0xcaef, 0xcaf1, 0xcbae, 0xf4cf, 0xcbca,
488 0xcbe6, 0xcbea, 0xcbf0, 0xcbf4, 0xcbee, 0xcca5, 0xcbf9, 0xccab,
489 0xccae, 0xccad, 0xccb2, 0xccc2, 0xccd0, 0xccd9, 0xf4d0, 0xcdbb,
490 0xf4d1, 0xcebb, 0xf4d2, 0xceba, 0xcec3, 0xf4d3, 0xcef2, 0xb3dd,
491 0xcfd5, 0xcfe2, 0xcfe9, 0xcfed, 0xf4d4, 0xf4d5, 0xf4d6, 0xffff,
492 0xf4d7, 0xd0e5, 0xf4d8, 0xd0e9, 0xd1e8, 0xf4d9, 0xf4da, 0xd1ec,
493 0xd2bb, 0xf4db, 0xd3e1, 0xd3e8, 0xd4a7, 0xf4dc, 0xf4dd, 0xd4d4,
494 0xd4f2, 0xd5ae, 0xf4de, 0xd7de, 0xf4df, 0xd8a2, 0xd8b7, 0xd8c1,
495 0xd8d1, 0xd8f4, 0xd9c6, 0xd9c8, 0xd9d1, 0xf4e0, 0xf4e1, 0xf4e2,
496 0xf4e3, 0xf4e4, 0xdcd3, 0xddc8, 0xddd4, 0xddea, 0xddfa, 0xdea4,
497 0xdeb0, 0xf4e5, 0xdeb5, 0xdecb, 0xf4e6, 0xdfb9, 0xf4e7, 0xdfc3,
498 0xf4e8, 0xf4e9, 0xe0d9, 0xf4ea, 0xf4eb, 0xe1e2, 0xf4ec, 0xf4ed,
499 0xf4ee, 0xe2c7, 0xe3a8, 0xe3a6, 0xe3a9, 0xe3af, 0xe3b0, 0xe3aa,
500 0xe3ab, 0xe3bc, 0xe3c1, 0xe3bf, 0xe3d5, 0xe3d8, 0xe3d6, 0xe3df,
501 0xe3e3, 0xe3e1, 0xe3d4, 0xe3e9, 0xe4a6, 0xe3f1, 0xe3f2, 0xe4cb,
502 0xe4c1, 0xe4c3, 0xe4be, 0xf4ef, 0xe4c0, 0xe4c7, 0xe4bf, 0xe4e0,
503 0xe4de, 0xe4d1, 0xf4f0, 0xe4dc, 0xe4d2, 0xe4db, 0xe4d4, 0xe4fa,
504 0xe4ef, 0xe5b3, 0xe5bf, 0xe5c9, 0xe5d0, 0xe5e2, 0xe5ea, 0xe5eb,
505 0xf4f1, 0xf4f2, 0xf4f3, 0xe6e8, 0xe6ef, 0xe7ac, 0xf4f4, 0xe7ae,
506 0xf4f5, 0xe7b1, 0xf4f6, 0xe7b2, 0xe8b1, 0xe8b6, 0xf4f7, 0xf4f8,
507 0xe8dd, 0xf4f9, 0xf4fa, 0xe9d1, 0xf4fb, 0xffff, 0xffff, 0xffff,
508 0xe9ed, 0xeacd, 0xf4fc, 0xeadb, 0xeae6, 0xeaea, 0xeba5, 0xebfb, /* 0xfc47 */
509 0xebfa, 0xf4fd, 0xecd6, 0xf4fe, 0xffff, 0xffff, 0xffff, 0xffff,
510 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
511 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
512 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
513 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
514 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
515 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
516 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
517 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
518 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
519 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
520 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
521 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
522 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
523 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
524 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
525 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
526 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
527 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
528 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
529 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
530 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
531 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff
532 };
533 /*
534  * jis208tosj1[]:
535  * Directly convert 1st octet of JISX0208 encoded 2bytes codes
536  * to the 1st octet of Shift-JIS encoded 2bytes codes.
537  * Because the 8th bit is always OFF, the size of this array
538  * can be limited to 128. (Precisely, 1st octet can vary between
539  * 0x21 and 0x7e, and the correspondent Shift-JIS code is
540  * between 0x81 and 0xfc. So we can use "0xff" as indicating invalid
541  * value.)
542  *
543  * Principal:
544  * 1: Index the array by using the value above as index number.
545  * 2: Value "0xff" means the index number is invalid or, there's
546  *    no Shift-JIS value that corresponds to.
547  *
548  * Note:
549  * 1: Some of Shift-JIS code points are mapped to JISX0208 plane
550  *    and others to JISX0212 plane.
551  *    Need to differentiate them before indexing and designate
552  *    appropriate character set. This table converts only code points
553  *    within each character set.
554  *
555  */
556 static const unsigned char jis208tosj1[] = {
557 /* Values never be indexed */
558 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
559 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
560 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
561 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
562 0xff,
563 /* Index 1KU - 62KU in JISX0208 */
564       0x81, 0x81, 0x82, 0x82, 0x83, 0x83, 0x84,
565 0x84, 0x85, 0x85, 0x86, 0x86, 0x87, 0x87, 0x88,
566 0x88, 0x89, 0x89, 0x8a, 0x8a, 0x8b, 0x8b, 0x8c,
567 0x8c, 0x8d, 0x8d, 0x8e, 0x8e, 0x8f, 0x8f, 0x90,
568 0x90, 0x91, 0x91, 0x92, 0x92, 0x93, 0x93, 0x94,
569 0x94, 0x95, 0x95, 0x96, 0x96, 0x97, 0x97, 0x98,
570 0x98, 0x99, 0x99, 0x9a, 0x9a, 0x9b, 0x9b, 0x9c,
571 0x9c, 0x9d, 0x9d, 0x9e, 0x9e, 0x9f, 0x9f,
572 /* Index 63KU - 84KU in JISX0208 */
573                                           0xe0,
574 0xe0, 0xe1, 0xe1, 0xe2, 0xe2, 0xe3, 0xe3, 0xe4,
575 0xe4, 0xe5, 0xe5, 0xe6, 0xe6, 0xe7, 0xe7, 0xe8,
576 0xe8, 0xe9, 0xe9, 0xea, 0xea,
577 /* Followings are mapped to "UDC" area in Shift-JIS */
578                               0xf0, 0xf0, 0xf1,
579 0xf1, 0xf2, 0xf2, 0xf3, 0xf3, 0xf4, 0xf4,
580 /* Values never be indexed */
581 0xff
582 };
583 
584 /*
585  * jis212tosj1[]:
586  * Directly convert 1st octet of JISX0212 encoded 2bytes codes
587  * to the 1st octet of Shift-JIS encoded 2bytes codes.
588  * Because the 8th bit is always OFF, the size of this array
589  * can be limited to 128. (Precisely, 1st octet can vary between
590  * 0x21 and 0x7e, and the correspondent Shift-JIS code is
591  * between 0x81 and 0xfc. So we can use "0xff" as indicating invalid
592  * value.)
593  *
594  * Principal:
595  * 1: Index the array by using the value above as index number.
596  * 2: Value "0xff" means the index number is invalid or, there's
597  *    no Shift-JIS value that corresponds to.
598  *
599  * Note:
600  * 1: Most G3 characters cannot map to Shift-JIS coded space.
601  *    (Such characters are mapped to unique code point. In this
602  *    table, it is 0x222e in JISX0208.)
603  * 2: Some of Shift-JIS code points are mapped to JISX0208 plane
604  *    and others to JISX0212 plane.
605  *    Need to differentiate them before indexing and designate
606  *    appropriate character set. This table converts only code points
607  *    within each character set.
608  *
609  */
610 static const unsigned char jis212tosj1[] = {
611 /* Values never be indexed */
612 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
613 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
614 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
615 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
616 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
617 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
618 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
619 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
620 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
621 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
622 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
623 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
624 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
625 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
626 /* Followings are mapped to "NEC/IBM(?)" area in Shift-JIS */
627 /*                                          0xfa,	*/
628 /* 0xfa, 0xfb, 0xfb, 0xfc, 0xfc,			*/
629                                           0xff,
630 0xff, 0xff, 0xff, 0xff, 0xff,
631 /* Followings are mapped to "UDC" area in Shift-JIS */
632                               0xf5, 0xf5, 0xf6,
633 0xf6, 0xf7, 0xf7, 0xf8, 0xf8, 0xf9, 0xf9,
634 /* Values never be indexed */
635 0xff
636 };
637 
638 /*
639  * jistosj2[]:
640  * Directly convert 2nd octet of 7bit-JIS encoded 2bytes codes
641  * to the 2nd octet of Shift-JIS encoded 2bytes codes.
642  * Although the source code may have the same value between
643  * JISX0208 and JISX0212, the destination code point can vary with regard to
644  * the eveness(oddness) of 'KU' number.
645  *
646  * Principal:
647  * 1: Add 0x80 if 'KU' number is even.
648  * 2: Index the array by using the value above as index number.
649  * 3: Value "0xff" means the index number is invalid or, there's
650  *    no Shift-JIS value that corresponds to.
651  *
652  * Note:
653  * 1: Use this table to map the 2nd octet of both JISX0208
654  *    and JISX0212.
655  *
656  */
657 static const unsigned char jistosj2[] = {
658 /* Values never be indexed */
659 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
660 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
661 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
662 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
663 0xff,
664 /* Index 1TEN - 63TEN in 'odd KU' */
665       0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46,
666 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e,
667 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56,
668 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e,
669 0x5f, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
670 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e,
671 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76,
672 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e,
673 /* Index 64TEN - 94TEN in 'odd KU' */
674 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
675 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
676 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
677 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e,
678 /* Values never be indexed */
679                                           0xff,
680 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
681 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
682 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
683 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
684 0xff,
685 /* Index 1TEN - 63TEN in 'even KU' */
686       0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5,
687 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad,
688 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5,
689 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd,
690 0xbe, 0xbf, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5,
691 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd,
692 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5,
693 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd,
694 0xde, 0xdf, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5,
695 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed,
696 0xee, 0xef, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5,
697 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc,
698 /* Values never be indexed */
699 0xff
700 };
701 
702 #define	JGETA	(0x222e)
703 #define	EGETA	(0xa2ae)
704 #define	PGETA	(0x81ac)
705 
706 /*
707  * Remap NEC/IBM codes to IBM codes
708  * if dest == 0xffff, that means the source
709  * code point is illegal in the current spec.
710  */
711 
712  #define REMAP_NEC(dest) \
713 	if ((0xed40 <= dest) && \
714 		(dest <= 0xed62)) { \
715 		dest += 0xd1c; \
716 	} else if ((0xed63 <= dest) && \
717 		(dest <= 0xed7e)) { \
718 		dest += 0xd1d; \
719 	} else if ((0xed80 <= dest) && \
720 		(dest <= 0xede0)) { \
721 		dest += 0xd1c; \
722 	} else if ((0xede1 <= dest) && \
723 		(dest <= 0xedfc)) { \
724 		dest += 0xd5f; \
725 	} else if ((0xee40 <= dest) && \
726 		(dest <= 0xee62)) { \
727 		dest += 0xd1c; \
728 	} else if ((0xee63 <= dest) && \
729 		(dest <= 0xee7e)) { \
730 		dest += 0xd1d; \
731 	} else if ((0xee80 <= dest) && \
732 		(dest <= 0xeee0)) { \
733 		dest += 0xd1c; \
734 	} else if ((0xeee1 <= dest) && \
735 		(dest <= 0xeeec)) { \
736 		dest += 0xd5f; \
737 	} else if ((0xeeef <= dest) && \
738 		(dest <= 0xeef8)) { \
739 		dest += 0xb51; \
740 	} else if ((0xeef9 <= dest) && \
741 		(dest <= 0xeefc)) { \
742 		dest += 0xb5b; \
743 	} else { \
744 		dest = 0xffff; \
745 	}
746 
747 #define CHECK2BIG(width,time) \
748 	if (oleft < (width)) { \
749 		int i; \
750 		for (i = time; i > 0; i--) { \
751 			UNGET(); \
752 		} \
753 		errno = E2BIG; \
754 		retval = (size_t)ERR_RETURN; \
755 		goto ret; \
756 	}
757 
758 /*
759  * halfkana2zenkakuj[]:
760  * Directly convert JIS X 0201 Kana (half width) to JIS X 0208
761  * Kana (full width).
762  * This table is for ISO-2022-JP.RFC1468 mode.
763  *
764  * Principal:
765  * 1: Subtract 0x21 or 0x81.
766  * 2: Index the array by using the value above as index number.
767  *
768  * Note:
769  */
770 static const unsigned short halfkana2zenkakuj[] = {
771 0x2123, 0x2156, 0x2157, 0x2122, 0x2126, 0x2572, 0x2521, 0x2523,
772 0x2525, 0x2527, 0x2529, 0x2563, 0x2565, 0x2567, 0x2543, 0x213c,
773 0x2522, 0x2524, 0x2526, 0x2528, 0x252a, 0x252b, 0x252d, 0x252f,
774 0x2531, 0x2533, 0x2535, 0x2537, 0x2539, 0x253b, 0x253d, 0x253f,
775 0x2541, 0x2544, 0x2546, 0x2548, 0x254a, 0x254b, 0x254c, 0x254d,
776 0x254e, 0x254f, 0x2552, 0x2555, 0x2558, 0x255b, 0x255e, 0x255f,
777 0x2560, 0x2561, 0x2562, 0x2564, 0x2566, 0x2568, 0x2569, 0x256a,
778 0x256b, 0x256c, 0x256d, 0x256f, 0x2573, 0x212b, 0x212c};
779 
780 /*
781  * halfkana2zenkakue[]:
782  * Directly convert JIS X 0201 Kana (half width) to JIS X 0208
783  * (eucJP).
784  * This table is for ISO-2022-JP.RFC1468 mode.
785  *
786  * Principal:
787  * 1: Subtract 0x21 or 0x81.
788  * 2: Index the array by using the value above as index number.
789  *
790  * Note:
791  */
792 static const unsigned short halfkana2zenkakue[] = {
793 0xa1a3, 0xa1d6, 0xa1d7, 0xa1a2, 0xa1a6, 0xa5f2, 0xa5a1,
794 0xa5a3, 0xa5a5, 0xa5a7, 0xa5a9, 0xa5e3, 0xa5e5, 0xa5e7,
795 0xa5c3, 0xa1bc, 0xa5a2, 0xa5a4, 0xa5a6, 0xa5a8, 0xa5aa,
796 0xa5ab, 0xa5ad, 0xa5af, 0xa5b1, 0xa5b3, 0xa5b5, 0xa5b7,
797 0xa5b9, 0xa5bb, 0xa5bd, 0xa5bf, 0xa5c1, 0xa5c4, 0xa5c6,
798 0xa5c8, 0xa5ca, 0xa5cb, 0xa5cc, 0xa5cd, 0xa5ce, 0xa5cf,
799 0xa5d2, 0xa5d5, 0xa5d8, 0xa5db, 0xa5de, 0xa5df, 0xa5e0,
800 0xa5e1, 0xa5e2, 0xa5e4, 0xa5e6, 0xa5e8, 0xa5e9, 0xa5ea,
801 0xa5eb, 0xa5ec, 0xa5ed, 0xa5ef, 0xa5f3, 0xa1ab, 0xa1ac};
802 
803 /*
804  * halfkana2zenkakus[]:
805  * Directly convert JIS X 0201 Kana (half width) to PCK Kana
806  * (full width).
807  * This table is for ISO-2022-JP.RFC1468 mode.
808  *
809  * Principal:
810  * 1: Subtract 0x21 or 0x81.
811  * 2: Index the array by using the value above as index number.
812  *
813  * Note:
814  */
815 static const unsigned short halfkana2zenkakus[] = {
816 0x8142, 0x8175, 0x8176, 0x8141, 0x8145, 0x8392, 0x8340, 0x8342,
817 0x8344, 0x8346, 0x8348, 0x8383, 0x8385, 0x8387, 0x8362, 0x815b,
818 0x8341, 0x8343, 0x8345, 0x8347, 0x8349, 0x834a, 0x834c, 0x834e,
819 0x8350, 0x8352, 0x8354, 0x8356, 0x8358, 0x835a, 0x835c, 0x835e,
820 0x8360, 0x8363, 0x8365, 0x8367, 0x8369, 0x836a, 0x836b, 0x836c,
821 0x836d, 0x836e, 0x8371, 0x8374, 0x8377, 0x837a, 0x837d, 0x837e,
822 0x8380, 0x8381, 0x8382, 0x8384, 0x8386, 0x8388, 0x8389, 0x838a,
823 0x838b, 0x838c, 0x838d, 0x838f, 0x8393, 0x814a, 0x814b};
824