116d8656Alexander Pyhalov/*
216d8656Alexander Pyhalov * CDDL HEADER START
316d8656Alexander Pyhalov *
416d8656Alexander Pyhalov * The contents of this file are subject to the terms of the
516d8656Alexander Pyhalov * Common Development and Distribution License (the "License").
616d8656Alexander Pyhalov * You may not use this file except in compliance with the License.
716d8656Alexander Pyhalov *
816d8656Alexander Pyhalov * You can obtain a copy of the license at src/OPENSOLARIS.LICENSE
916d8656Alexander Pyhalov * or http://www.opensolaris.org/os/licensing.
1016d8656Alexander Pyhalov * See the License for the specific language governing permissions
1116d8656Alexander Pyhalov * and limitations under the License.
1216d8656Alexander Pyhalov *
1316d8656Alexander Pyhalov * When distributing Covered Code, include this CDDL HEADER in each
1416d8656Alexander Pyhalov * file and include the License file at src/OPENSOLARIS.LICENSE.
1516d8656Alexander Pyhalov * If applicable, add the following below this CDDL HEADER, with the
1616d8656Alexander Pyhalov * fields enclosed by brackets "[]" replaced with your own identifying
1716d8656Alexander Pyhalov * information: Portions Copyright [yyyy] [name of copyright owner]
1816d8656Alexander Pyhalov *
1916d8656Alexander Pyhalov * CDDL HEADER END
2016d8656Alexander Pyhalov */
2116d8656Alexander Pyhalov/*
2216d8656Alexander Pyhalov * COPYRIGHT AND PERMISSION NOTICE
2316d8656Alexander Pyhalov *
2416d8656Alexander Pyhalov * Copyright (c) 1991-2005 Unicode, Inc. All rights reserved. Distributed
2516d8656Alexander Pyhalov * under the Terms of Use in http://www.unicode.org/copyright.html.
2616d8656Alexander Pyhalov *
2716d8656Alexander Pyhalov * This file has been modified by Sun Microsystems, Inc.
2816d8656Alexander Pyhalov */
2916d8656Alexander Pyhalov/*
3016d8656Alexander Pyhalov * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
3116d8656Alexander Pyhalov * Use is subject to license terms.
3216d8656Alexander Pyhalov */
3316d8656Alexander Pyhalov
3416d8656Alexander Pyhalov
3516d8656Alexander Pyhalov#define GET(c)		((c) = *ip, ip++, ileft--)
3616d8656Alexander Pyhalov#define PUT(c)		(*op = (c), op++, oleft--)
3716d8656Alexander Pyhalov#define UNGET()		(ip--, ileft++)
3816d8656Alexander Pyhalov
3916d8656Alexander Pyhalov#if	defined(DEBUG)
4016d8656Alexander Pyhalov#include <stdio.h>
4116d8656Alexander Pyhalovstatic const char	*debugmsg = "<empty>";
4216d8656Alexander Pyhalov#define	DEBUGMSG(msg)	debugmsg = (msg);
4316d8656Alexander Pyhalov#else	/* ! DEBUG */
4416d8656Alexander Pyhalov#define	DEBUGMSG(msg)	;
4516d8656Alexander Pyhalov#endif	/* DEBUG */
4616d8656Alexander Pyhalov
4716d8656Alexander Pyhalov#define	RETERROR(no, msg) {\
4816d8656Alexander Pyhalov		errno = (no);\
4916d8656Alexander Pyhalov		DEBUGMSG(msg);\
5016d8656Alexander Pyhalov		rv = ((size_t)-1);\
5116d8656Alexander Pyhalov		goto ret;\
5216d8656Alexander Pyhalov	}
5316d8656Alexander Pyhalov
5416d8656Alexander Pyhalov#if	defined(DEBUG)
5516d8656Alexander Pyhalov#define	DEBUGPRINTERROR \
5616d8656Alexander Pyhalov	if (rv == (size_t)-1) { \
5716d8656Alexander Pyhalov		if (errno == EILSEQ) { \
5816d8656Alexander Pyhalov			fprintf(stderr, "DEBUG: EILSEQ: %s\n", debugmsg); \
5916d8656Alexander Pyhalov		} else if (errno == E2BIG) { \
6016d8656Alexander Pyhalov			fprintf(stderr, "DEBUG: E2BIG: %s\n", debugmsg); \
6116d8656Alexander Pyhalov		} else if (errno == EINVAL) { \
6216d8656Alexander Pyhalov			fprintf(stderr, "DEBUG: EINVAL: %s\n", debugmsg); \
6316d8656Alexander Pyhalov		} else { \
6416d8656Alexander Pyhalov			fprintf(stderr, \
6516d8656Alexander Pyhalov			"DEBUG: errno=%d: %s\n", errno, debugmsg); \
6616d8656Alexander Pyhalov		} \
6716d8656Alexander Pyhalov	}
6816d8656Alexander Pyhalov#else	/* !DEBUG */
6916d8656Alexander Pyhalov#define	DEBUGPRINTERROR	/* nop */
7016d8656Alexander Pyhalov#endif	/* DEBUG */
7116d8656Alexander Pyhalov
7216d8656Alexander Pyhalov#define NGET(c, msg) \
7316d8656Alexander Pyhalov	if (ileft-- == 0) {\
7416d8656Alexander Pyhalov		RETERROR(EINVAL, msg)\
7516d8656Alexander Pyhalov	} else {\
7616d8656Alexander Pyhalov		(c) = *ip++;\
7716d8656Alexander Pyhalov	}
7816d8656Alexander Pyhalov
7916d8656Alexander Pyhalov#define NPUT(c, msg) \
8016d8656Alexander Pyhalov	if (oleft-- == 0) {\
8116d8656Alexander Pyhalov		RETERROR(E2BIG, msg)\
8216d8656Alexander Pyhalov	} else {\
8316d8656Alexander Pyhalov		*op++ = (c);\
8416d8656Alexander Pyhalov	}
8516d8656Alexander Pyhalov
8616d8656Alexander Pyhalov/* to be obsoleted; migrate to PUTU() in jfp_iconv_unicode.h */
8716d8656Alexander Pyhalov#if	defined(JFP_ICONV_TOCODE_UCS2)
8816d8656Alexander Pyhalov#define	PUTUCS2(uni, msg)	\
8916d8656Alexander Pyhalov	if (write_unicode((unsigned int)uni, &op, &oleft, little, msg) \
9016d8656Alexander Pyhalov			== (size_t)-1) { \
9116d8656Alexander Pyhalov		rv = ((size_t)-1);\
9216d8656Alexander Pyhalov		goto ret; \
9316d8656Alexander Pyhalov	}
9416d8656Alexander Pyhalov#else	/* !JFP_ICONV_TOCODE_UCS2 */
9516d8656Alexander Pyhalov#define	PUTUCS2(ucs2, msg)	\
9616d8656Alexander Pyhalov	if (ucs2 <= 0x7f) {\
9716d8656Alexander Pyhalov		NPUT((unsigned char)(ucs2), msg);\
9816d8656Alexander Pyhalov	} else if (ucs2 <= 0x7ff) {\
9916d8656Alexander Pyhalov		NPUT((unsigned char)((((ucs2)>>6) & 0x1f) | 0xc0), msg);\
10016d8656Alexander Pyhalov		NPUT((unsigned char)((((ucs2)>>0) & 0x3f) | 0x80), msg);\
10116d8656Alexander Pyhalov	} else {\
10216d8656Alexander Pyhalov		NPUT((unsigned char)((((ucs2)>>12) & 0x0f) | 0xe0), msg);\
10316d8656Alexander Pyhalov		NPUT((unsigned char)((((ucs2)>>6) & 0x3f) | 0x80), msg);\
10416d8656Alexander Pyhalov		NPUT((unsigned char)((((ucs2)>>0) & 0x3f) | 0x80), msg);\
10516d8656Alexander Pyhalov	}
10616d8656Alexander Pyhalov#endif	/* JFP_ICONV_TOCODE_UCS2 */
10716d8656Alexander Pyhalov
10816d8656Alexander Pyhalov#if	defined(JFP_ICONV_STATELESS)
10916d8656Alexander Pyhalov
11016d8656Alexander Pyhalov#include	<stdlib.h>
11116d8656Alexander Pyhalov
11216d8656Alexander Pyhalovstatic void *
11316d8656Alexander Pyhalov_icv_open_stateless(void)
11416d8656Alexander Pyhalov{
11516d8656Alexander Pyhalov	void	*cd;
11616d8656Alexander Pyhalov
11716d8656Alexander Pyhalov	/*
11816d8656Alexander Pyhalov	 * Do malloc() only to get address as unique conversion descriptor.
11916d8656Alexander Pyhalov	 * Though iconv() specification doesn't describe the uniqueness,
12016d8656Alexander Pyhalov	 * some existing applications may be assuming it.
12116d8656Alexander Pyhalov	 * Unless call of malloc() here is raised as a problem, keep away
12216d8656Alexander Pyhalov	 * from breaking the assumption.
12316d8656Alexander Pyhalov	 */
12416d8656Alexander Pyhalov
12516d8656Alexander Pyhalov	if ((cd = malloc((size_t)1)) == NULL) {
12616d8656Alexander Pyhalov		errno = ENOMEM;
12716d8656Alexander Pyhalov		return ((void *)-1);
12816d8656Alexander Pyhalov	} else {
12916d8656Alexander Pyhalov		return (cd);
13016d8656Alexander Pyhalov	}
13116d8656Alexander Pyhalov}
13216d8656Alexander Pyhalov
13316d8656Alexander Pyhalovstatic void
13416d8656Alexander Pyhalov_icv_close_stateless(void *cd)
13516d8656Alexander Pyhalov{
13616d8656Alexander Pyhalov	if (cd == NULL) {
13716d8656Alexander Pyhalov		errno = EBADF;
13816d8656Alexander Pyhalov	} else {
13916d8656Alexander Pyhalov		free(cd);
14016d8656Alexander Pyhalov	}
14116d8656Alexander Pyhalov	return;
14216d8656Alexander Pyhalov}
14316d8656Alexander Pyhalov
14416d8656Alexander Pyhalov#endif	/* ! JFP_ICONV_STATELESS */
14516d8656Alexander Pyhalov
14616d8656Alexander Pyhalov#define ERR_RETURN	(-1)		/* result code on error */
14716d8656Alexander Pyhalov
14816d8656Alexander Pyhalov/*
14916d8656Alexander Pyhalov * ISXXXX(c) macros below assume (c) is of type unsigned char
15016d8656Alexander Pyhalov */
15116d8656Alexander Pyhalov/* is a valid code as ascii? */
15216d8656Alexander Pyhalov#define ISASC(c)		((c) <= 0x7f)
15316d8656Alexander Pyhalov
15416d8656Alexander Pyhalov/* is a valid code as C1 control? */
15516d8656Alexander Pyhalov#define ISC1CTRL(c)		(((c) >= 0x80) && ((c) <= 0x9f))
15616d8656Alexander Pyhalov
15716d8656Alexander Pyhalov/* is a valid code as C1 control allowed in EUC? */
15816d8656Alexander Pyhalov#define ISC1CTRLEUC(c)		((((c) >= 0x80) && ((c) <= 0x8d)) ||\
15916d8656Alexander Pyhalov					(((c) >= 0x90) && ((c) <= 0x9f)))
16016d8656Alexander Pyhalov
16116d8656Alexander Pyhalov/* is a valid 1st or 2nd byte of EUC codeset 1? */
16216d8656Alexander Pyhalov#define ISCS1(c)		(((c) >= 0xa1) && ((c) <= 0xfe))
16316d8656Alexander Pyhalov
16416d8656Alexander Pyhalov/* is a valid 1st byte of EUC codeset 1 and in range row 1 thru 84? */
16516d8656Alexander Pyhalov#define ISCS1_0208(c)		(((c) >= 0xa1) && ((c) <= 0xf4))
16616d8656Alexander Pyhalov
16716d8656Alexander Pyhalov/* is a valid 1st byte of UDC area in EUC codeset 1? */
16816d8656Alexander Pyhalov#define ISCS1_UDC(c)		(((c) >= 0xf5) && ((c) <= 0xfe))
16916d8656Alexander Pyhalov
17016d8656Alexander Pyhalov/* is a valid 2nd (1st byte is SS2) byte of EUC codeset 2? */
17116d8656Alexander Pyhalov#define ISCS2(c)		(((c) >= 0xa1) && ((c) <= 0xdf))
17216d8656Alexander Pyhalov
17316d8656Alexander Pyhalov/* is a valid 2nd or 3rd (1st byte is SS3) byte of EUC codeset 3? */
17416d8656Alexander Pyhalov#define ISCS3(c)		(((c) >= 0xa1) && ((c) <= 0xfe))
17516d8656Alexander Pyhalov
17616d8656Alexander Pyhalov/* is a valid 2nd (1st byte is SS3) byte of UDC area in EUC codeset 3? */
17716d8656Alexander Pyhalov#define ISCS3_UDC(c)		(((c) >= 0xf5) && ((c) <= 0xfe))
17816d8656Alexander Pyhalov
17916d8656Alexander Pyhalov/* is a valid hankaku_katakana for SJIS? */
18016d8656Alexander Pyhalov#define ISSJKANA(c)		(((c) >= 0xa1) && ((c) <= 0xdf))
18116d8656Alexander Pyhalov
18216d8656Alexander Pyhalov/* is a valid character for the first byte of SJIS multibyte? */
18316d8656Alexander Pyhalov#define ISSJMB_1(c)	((((c) >= 0x81) && ((c) <= 0x9f)) ||\
18416d8656Alexander Pyhalov				 (((c) >= 0xe0) && ((c) <= 0xfc)))
18516d8656Alexander Pyhalov
18616d8656Alexander Pyhalov/* is a valid character for the first byte of SJIS kanji? */
18716d8656Alexander Pyhalov#define ISSJKANJI1(c)	((((c) >= 0x81) && ((c) <= 0x9f)) ||\
18816d8656Alexander Pyhalov				 (((c) >= 0xe0) && ((c) <= 0xea)) ||\
18916d8656Alexander Pyhalov				 (((c) >= 0xf0) && ((c) <= 0xf4)))
19016d8656Alexander Pyhalov
19116d8656Alexander Pyhalov/* is a valid character for the first byte of a part of Suppl. SJIS? */
19216d8656Alexander Pyhalov#define ISSJSUPKANJI1(c)	(((c) >= 0xf5) && ((c) <= 0xf9))
19316d8656Alexander Pyhalov
19416d8656Alexander Pyhalov/* is a valid character for the first byte of SJIS UDC? */
19516d8656Alexander Pyhalov#define ISSJUDC_1(c)		(((c) >= 0xf0) && ((c) <= 0xf9))
19616d8656Alexander Pyhalov
19716d8656Alexander Pyhalov/* is a valid character for the first byte of ibm character set */
19816d8656Alexander Pyhalov#define	ISSJIBM(c)		(((c) >= 0xfa) && ((c) <= 0xfc))
19916d8656Alexander Pyhalov
20016d8656Alexander Pyhalov/* is a valid character for the first byte of ibm character set */
20116d8656Alexander Pyhalov#define	ISSJNECIBM(c)		(((c) >= 0xed) && ((c) <= 0xef))
20216d8656Alexander Pyhalov
20316d8656Alexander Pyhalov/* is a valid character for the second byte of SJIS kanji? */
20416d8656Alexander Pyhalov#define ISSJKANJI2(c)	((((c) >= 0x40) && ((c) <= 0x7e)) ||\
20516d8656Alexander Pyhalov					 (((c) >= 0x80) && ((c) <= 0xfc)))
20616d8656Alexander Pyhalov
20716d8656Alexander Pyhalov/* is a valid character for UTF8 UDC ? */
20816d8656Alexander Pyhalov#define ISUTF8UDC(c)	(((c) >= 0xe000) && ((c) <= 0xf8ff))
20916d8656Alexander Pyhalov
21016d8656Alexander Pyhalov#define CS_0			0		/* codeset 0 */
21116d8656Alexander Pyhalov#define CS_1			1		/* codeset 1 */
21216d8656Alexander Pyhalov#define CS_2			2		/* codeset 2 */
21316d8656Alexander Pyhalov#define CS_3			3		/* codeset 3 */
21416d8656Alexander Pyhalov
21516d8656Alexander Pyhalov#define ST_INIT			0		/* init */
21616d8656Alexander Pyhalov#define ST_INCS1		1		/* in codeset 1 */
21716d8656Alexander Pyhalov#define ST_INCS2		2		/* in codeset 2 */
21816d8656Alexander Pyhalov#define ST_INCS3		3		/* in codeset 3 */
21916d8656Alexander Pyhalov#define ST_ESC			4		/* in ESC */
22016d8656Alexander Pyhalov#define ST_MBTOG0_1		5		/* in the designation of MB to G0 - 1 */
22116d8656Alexander Pyhalov#define ST_MBTOG0_2		6		/* in the designation of MB to G0 - 2 */
22216d8656Alexander Pyhalov#define ST_SBTOG0		7		/* in the designation of SB to G0 */
22316d8656Alexander Pyhalov#define ST_208REV_1		8		/* in the designation of JISX208-1990 */
22416d8656Alexander Pyhalov#define ST_208REV_2		9		/* in the designation of JISX208-1990 */
22516d8656Alexander Pyhalov#define ST_REV_AFT_ESC		10		/* in the designation of JISX208-1990 */
22616d8656Alexander Pyhalov#define ST_REV_AFT_MBTOG0_1	11		/* in the designation of JISX208-1990 */
22716d8656Alexander Pyhalov#define ST_REV_AFT_MBTOG0_2	12		/* in the designation of JISX208-1990 */
22816d8656Alexander Pyhalov
22916d8656Alexander Pyhalov/*
23016d8656Alexander Pyhalov * CODE SET 0
23116d8656Alexander Pyhalov * ESC ( B   			: To ASCII
23216d8656Alexander Pyhalov * ESC ( J			: To JIS X 0201 - 1976 ROMAN
23316d8656Alexander Pyhalov * ESC ( @			: TO ISO 646 IRV
23416d8656Alexander Pyhalov *
23516d8656Alexander Pyhalov * CODE SET 1
23616d8656Alexander Pyhalov * ESC & @ ESC $ ( B		: To JIS X 0208 - 1990
23716d8656Alexander Pyhalov * ESC $ ( B			: To JIS X 0208 - 1983/1990
23816d8656Alexander Pyhalov * ESC $ ( @			: To JIS X 0208 - 1978
23916d8656Alexander Pyhalov * ESC $ B			: To JIS X 0208 - 1983/1990
24016d8656Alexander Pyhalov * ESC $ @			: To JIS X 0208 - 1978
24116d8656Alexander Pyhalov * ESC & @ ESC $ B		: To JIS X 0208 - 1983/1990
24216d8656Alexander Pyhalov *
24316d8656Alexander Pyhalov * CODE SET 2
24416d8656Alexander Pyhalov * SO  					: G1 -> G
24516d8656Alexander Pyhalov * SI  					: G0 -> G
24616d8656Alexander Pyhalov * ESC ( I				: To JIS X 0201 - 1976 Katakana
24716d8656Alexander Pyhalov *
24816d8656Alexander Pyhalov * CODE SET 3
24916d8656Alexander Pyhalov * ESC $ ( D			: To JIS X 0212 - 1990
25016d8656Alexander Pyhalov * ESC $ D			: To JIS X 0212 - 1990
25116d8656Alexander Pyhalov *
25216d8656Alexander Pyhalov */
25316d8656Alexander Pyhalov
25416d8656Alexander Pyhalov#define ESC				0x1b		/* Escape : 1/12 */
25516d8656Alexander Pyhalov#define SO				0x0e		/* Shift Out : 0/14 */
25616d8656Alexander Pyhalov#define SI				0x0f		/* Shift In  : 0/15 */
25716d8656Alexander Pyhalov
25816d8656Alexander Pyhalov#define SBTOG0_1			0x28		/* ( : 2/8 */
25916d8656Alexander Pyhalov#define F_ASCII				0x42		/* B : 4/2 */
26016d8656Alexander Pyhalov#define F_X0201_RM			0x4a		/* J : 4/10 */
26116d8656Alexander Pyhalov#define F_ISO646			0x40		/* @ : 4/0 */
26216d8656Alexander Pyhalov#define F_X0201_KN			0x49		/* I : 4/9 */
26316d8656Alexander Pyhalov
26416d8656Alexander Pyhalov#define MBTOG0_1			0x24		/* $ : 2/4 */
26516d8656Alexander Pyhalov#define MBTOG0_2			0x28		/* ( : 2/8 */
26616d8656Alexander Pyhalov#define F_X0208_83_90			0x42		/* B : 4/2 */
26716d8656Alexander Pyhalov#define F_X0208_78			0x40		/* @ : 4/0 */
26816d8656Alexander Pyhalov#define F_X0212_90			0x44		/* D : 4/4 */
26916d8656Alexander Pyhalov#define	X208REV_1			0x26		/* & : 2/6 */
27016d8656Alexander Pyhalov#define	X208REV_2			0x40		/* @ : 4/0 */
27116d8656Alexander Pyhalov
27216d8656Alexander Pyhalov#define	CMASK				0x7f
27316d8656Alexander Pyhalov#define	CMSB				0x80
27416d8656Alexander Pyhalov
27516d8656Alexander Pyhalov/* the byte length of ESC sequences */
27616d8656Alexander Pyhalov#define SEQ_SBTOG0			3			/* ESC + ( + F */
27716d8656Alexander Pyhalov#define SEQ_MBTOG0			4			/* ESC + $ + ( + F */
27816d8656Alexander Pyhalov#define SEQ_MBTOG0_O			3			/* ESC + $ + F */
27916d8656Alexander Pyhalov
28016d8656Alexander Pyhalov/* the byte length of SO/SI */
28116d8656Alexander Pyhalov#define SEQ_SOSI			1			/* SO or SI */
28216d8656Alexander Pyhalov
28316d8656Alexander Pyhalov/* the byte length of SS2/SS3 */
28416d8656Alexander Pyhalov#define SEQ_SS				1			/* SS2 or SS3 */
28516d8656Alexander Pyhalov
28616d8656Alexander Pyhalov/* the byte length of JIS characters */
28716d8656Alexander Pyhalov#define JISW0				1			/* ASCII */
28816d8656Alexander Pyhalov#define JISW1				2			/* Kanji */
28916d8656Alexander Pyhalov#define JISW2				1			/* Hankaku Katakana */
29016d8656Alexander Pyhalov#define JISW3				2			/* Hojo Kanji */
29116d8656Alexander Pyhalov
29216d8656Alexander Pyhalov/* the byte length of EUC characters */
29316d8656Alexander Pyhalov#define EUCW0				1			/* ASCII */
29416d8656Alexander Pyhalov#define EUCW1				2			/* Kanji */
29516d8656Alexander Pyhalov#define EUCW2				1			/* Hankaku Katakana */
29616d8656Alexander Pyhalov#define EUCW3				2			/* Hojo Kanji */
29716d8656Alexander Pyhalov#define SS2W				1			/* SS2 */
29816d8656Alexander Pyhalov#define SS3W				1			/* SS3 */
29916d8656Alexander Pyhalov
30016d8656Alexander Pyhalov/* the byte length of SJIS characters */
30116d8656Alexander Pyhalov#define SJISW0				1			/* ASCII */
30216d8656Alexander Pyhalov#define SJISW1				2			/* Kanji/UDC */
30316d8656Alexander Pyhalov#define SJISW2				1			/* Hankaku Katakana */
30416d8656Alexander Pyhalov
30516d8656Alexander Pyhalov#define EBCDIC0				1
30616d8656Alexander Pyhalov#define EBCDIC1				2
30716d8656Alexander Pyhalov#define EBCDIC2				1
30816d8656Alexander Pyhalov#define EBCDIC3				2
30916d8656Alexander Pyhalov
31016d8656Alexander Pyhalov/* the byte length of unknown characters */
31116d8656Alexander Pyhalov#define UNKNOWNW			1
31216d8656Alexander Pyhalov
31316d8656Alexander Pyhalov#define	TRUE	(1)
31416d8656Alexander Pyhalov#define	FALSE	(0)
31516d8656Alexander Pyhalov
31616d8656Alexander Pyhalov/*
31716d8656Alexander Pyhalov * sjtojis1[]:
31816d8656Alexander Pyhalov * Directly convert 1st octet of Shift-JIS encoded 2bytes codes
31916d8656Alexander Pyhalov * to the 1st octet of 7bit-JIS encoded 2bytes codes.
32016d8656Alexander Pyhalov * Because the 8th bit is always ON, the size of this array
32116d8656Alexander Pyhalov * can be limited to 128. (Precisely, 1st octet can vary between
32216d8656Alexander Pyhalov * 0x81 and 0xfc, and correspondent 7bit-JIS value is between
32316d8656Alexander Pyhalov * 0x21 and 0x7e. So we can use "0xff" as indicating invalid value.)
32416d8656Alexander Pyhalov *
32516d8656Alexander Pyhalov * Principal:
32616d8656Alexander Pyhalov * 1: Subtract 0x80
32716d8656Alexander Pyhalov * 2: Index the array by using the value above as index number.
32816d8656Alexander Pyhalov * 3: Value "0xff" means the index number is invalid or, there's
32916d8656Alexander Pyhalov *    no 7bit-JIS value that corresponds to.
33016d8656Alexander Pyhalov *
33116d8656Alexander Pyhalov * Note:
33216d8656Alexander Pyhalov * 1: When the 2nd octet of Shift-JIS encoded 2bytes codes is
33316d8656Alexander Pyhalov *    more than 0x9f, indexed value should be augumented by 1.
33416d8656Alexander Pyhalov * 2: Some of Shift-JIS code points are mapped to JISX0208 plane
33516d8656Alexander Pyhalov *    and others are JISX0212 plane.
33616d8656Alexander Pyhalov *    Need to differentiate them before indexing and designate
33716d8656Alexander Pyhalov *    appropriate character set. This table converts only code points
33816d8656Alexander Pyhalov *    within each character set.
33916d8656Alexander Pyhalov *
34016d8656Alexander Pyhalov */
34116d8656Alexander Pyhalovstatic const unsigned char sjtojis1[] = {
34216d8656Alexander Pyhalov/* Values never be indexed */
34316d8656Alexander Pyhalov0xff,
34416d8656Alexander Pyhalov/* Index 1KU - 62KU in JISX0208 */
34516d8656Alexander Pyhalov0x21, 0x23, 0x25, 0x27, 0x29, 0x2b, 0x2d, 0x2f,
34616d8656Alexander Pyhalov0x31, 0x33, 0x35, 0x37, 0x39, 0x3b, 0x3d, 0x3f,
34716d8656Alexander Pyhalov0x41, 0x43, 0x45, 0x47, 0x49, 0x4b, 0x4d, 0x4f,
34816d8656Alexander Pyhalov0x51, 0x53, 0x55, 0x57, 0x59, 0x5b, 0x5d,
34916d8656Alexander Pyhalov/* Values never be indexed */
35016d8656Alexander Pyhalov0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
35116d8656Alexander Pyhalov0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
35216d8656Alexander Pyhalov0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
35316d8656Alexander Pyhalov0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
35416d8656Alexander Pyhalov0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
35516d8656Alexander Pyhalov0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
35616d8656Alexander Pyhalov0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
35716d8656Alexander Pyhalov0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
35816d8656Alexander Pyhalov/* Index 63KU - 84KU in JISX0208 */
35916d8656Alexander Pyhalov                                          0x5f,
36016d8656Alexander Pyhalov0x61, 0x63, 0x65, 0x67, 0x69, 0x6b, 0x6d, 0x6f,
36116d8656Alexander Pyhalov0x71, 0x73,
36216d8656Alexander Pyhalov/* Values never be indexed */
36316d8656Alexander Pyhalov0xff, 0xff,
36416d8656Alexander Pyhalov/* Followings will be mapped to 79KU - 84KU in JISX0212 (NEC/IBM) */
36516d8656Alexander Pyhalov/* 0x6f, 0x71, 0x73,						*/
36616d8656Alexander Pyhalov0xff, 0xff, 0xff,
36716d8656Alexander Pyhalov/* Followings will be mapped to 85KU - 94KU in JISX0208 (UDC) */
36816d8656Alexander Pyhalov0x75, 0x77, 0x79, 0x7b, 0x7d,
36916d8656Alexander Pyhalov/* Followings will be mapped to 85KU - 94KU in JISX0212 (UDC) */
37016d8656Alexander Pyhalov0x75, 0x77, 0x79, 0x7b, 0x7d,
37116d8656Alexander Pyhalov/* Followings will be mapped to 79KU - 84KU in JISX0212 (IBM) */
37216d8656Alexander Pyhalov/* 0x6f, 0x71, 0x73,						*/
37316d8656Alexander Pyhalov0xff, 0xff, 0xff,
37416d8656Alexander Pyhalov/* Values never be indexed */
37516d8656Alexander Pyhalov0xff, 0xff, 0xff
37616d8656Alexander Pyhalov};
37716d8656Alexander Pyhalov
37816d8656Alexander Pyhalov/*
37916d8656Alexander Pyhalov * sjtojis2[]:
38016d8656Alexander Pyhalov * Directly convert 2nd octet of Shift-JIS encoded 2bytes codes
38116d8656Alexander Pyhalov * to the 2nd octet of 7bit-JIS encoded 2bytes codes.
38216d8656Alexander Pyhalov * 2nd octet in Shift-JIS can vary between 0x40 and 0xfc(except 0x7f)
38316d8656Alexander Pyhalov * and the correspondent 7bit-JIS octet is between 0x21 and 0x7e.
38416d8656Alexander Pyhalov * (So we can use '0xff' as indicating invalid value.)
38516d8656Alexander Pyhalov *
38616d8656Alexander Pyhalov * Principal:
38716d8656Alexander Pyhalov * 1: Index the array by using the value above as index number.
38816d8656Alexander Pyhalov * 2: Value "0xff" means the index number is invalid or, there's
38916d8656Alexander Pyhalov *    no 7bit-JIS value that corresponds to.
39016d8656Alexander Pyhalov *
39116d8656Alexander Pyhalov * Note:
39216d8656Alexander Pyhalov * 1: Some of Shift-JIS code points are mapped to JISX0208 plane
39316d8656Alexander Pyhalov *    and others to JISX0212 plane.
39416d8656Alexander Pyhalov *    Need to differentiate them before indexing and designate
39516d8656Alexander Pyhalov *    appropriate character set. This table converts only code points
39616d8656Alexander Pyhalov *    within each character set.
39716d8656Alexander Pyhalov *
39816d8656Alexander Pyhalov */
39916d8656Alexander Pyhalovstatic const unsigned char sjtojis2[] = {
40016d8656Alexander Pyhalov/* Values never be indexed */
40116d8656Alexander Pyhalov0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
40216d8656Alexander Pyhalov0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
40316d8656Alexander Pyhalov0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
40416d8656Alexander Pyhalov0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
40516d8656Alexander Pyhalov0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
40616d8656Alexander Pyhalov0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
40716d8656Alexander Pyhalov0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
40816d8656Alexander Pyhalov0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
40916d8656Alexander Pyhalov/* Followings are 2nd octet for 'odd' KU */
41016d8656Alexander Pyhalov0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
41116d8656Alexander Pyhalov0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30,
41216d8656Alexander Pyhalov0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
41316d8656Alexander Pyhalov0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40,
41416d8656Alexander Pyhalov0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
41516d8656Alexander Pyhalov0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
41616d8656Alexander Pyhalov0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
41716d8656Alexander Pyhalov0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
41816d8656Alexander Pyhalov/* Values never be indexed */
41916d8656Alexander Pyhalov0xff,
42016d8656Alexander Pyhalov/* Followings are 2nd octet for 'odd' KU */
42116d8656Alexander Pyhalov                                          0x60,
42216d8656Alexander Pyhalov0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
42316d8656Alexander Pyhalov0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70,
42416d8656Alexander Pyhalov0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
42516d8656Alexander Pyhalov0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e,
42616d8656Alexander Pyhalov/* Followings are 2nd octet for 'even' KU */
42716d8656Alexander Pyhalov0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
42816d8656Alexander Pyhalov0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30,
42916d8656Alexander Pyhalov0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
43016d8656Alexander Pyhalov0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40,
43116d8656Alexander Pyhalov0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
43216d8656Alexander Pyhalov0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
43316d8656Alexander Pyhalov0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
43416d8656Alexander Pyhalov0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60,
43516d8656Alexander Pyhalov0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
43616d8656Alexander Pyhalov0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70,
43716d8656Alexander Pyhalov0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
43816d8656Alexander Pyhalov0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e,
43916d8656Alexander Pyhalov/* Values never be indexed */
44016d8656Alexander Pyhalov0xff, 0xff, 0xff
44116d8656Alexander Pyhalov};
44216d8656Alexander Pyhalov
44316d8656Alexander Pyhalov/*
44416d8656Alexander Pyhalov * sjtoibmext[]:
44516d8656Alexander Pyhalov * Directly convert Shift-JIS encoded 2bytes codes
44616d8656Alexander Pyhalov * to the EUC encoded 2bytes codes.
44716d8656Alexander Pyhalov * This table is used for "IBM Extended Character Set" only.
44816d8656Alexander Pyhalov *
44916d8656Alexander Pyhalov * Principal:
45016d8656Alexander Pyhalov * 1: Subtract 0xfa40.
45116d8656Alexander Pyhalov * 2: Index the array by using the value above as index number.
45216d8656Alexander Pyhalov * 3: Value "0xffff" means the index number is invalid or, there's
45316d8656Alexander Pyhalov *    no EUC value that corresponds to.
45416d8656Alexander Pyhalov *
45516d8656Alexander Pyhalov * Note: The SJIS code points, 0xfa54 and 0xfa5b are mapped to JIS208
45616d8656Alexander Pyhalov *       hence they are NOT mapped with tables below.
45716d8656Alexander Pyhalov *       (They are mapped to 0xa2cc and 0xa2e8 in JIS208 respectively.)
45816d8656Alexander Pyhalov */
45916d8656Alexander Pyhalovstatic const unsigned short sjtoibmext[] = {
46016d8656Alexander Pyhalov0xf3f3, 0xf3f4, 0xf3f5, 0xf3f6, 0xf3f7, 0xf3f8, 0xf3f9, 0xf3fa, /* 0xfa47 */
46116d8656Alexander Pyhalov0xf3fb, 0xf3fc, 0xf3fd, 0xf3fe, 0xf4a1, 0xf4a2, 0xf4a3, 0xf4a4,
46216d8656Alexander Pyhalov0xf4a5, 0xf4a6, 0xf4a7, 0xf4a8, 0xffff, 0xa2c3, 0xf4a9, 0xf4aa,
46316d8656Alexander Pyhalov0xf4ab, 0xf4ac, 0xf4ad, 0xffff, 0xd4e3, 0xdcdf, 0xe4e9, 0xe3f8,
46416d8656Alexander Pyhalov0xd9a1, 0xb1bb, 0xf4ae, 0xc2ad, 0xc3fc, 0xe4d0, 0xc2bf, 0xbcf4,
46516d8656Alexander Pyhalov0xb0a9, 0xb0c8, 0xf4af, 0xb0d2, 0xb0d4, 0xb0e3, 0xb0ee, 0xb1a7,
46616d8656Alexander Pyhalov0xb1a3, 0xb1ac, 0xb1a9, 0xb1be, 0xb1df, 0xb1d8, 0xb1c8, 0xb1d7,
46716d8656Alexander Pyhalov0xb1e3, 0xb1f4, 0xb1e1, 0xb2a3, 0xf4b0, 0xb2bb, 0xb2e6, 0xffff,
46816d8656Alexander Pyhalov0xb2ed, 0xb2f5, 0xb2fc, 0xf4b1, 0xb3b5, 0xb3d8, 0xb3db, 0xb3e5,
46916d8656Alexander Pyhalov0xb3ee, 0xb3fb, 0xf4b2, 0xf4b3, 0xb4c0, 0xb4c7, 0xb4d0, 0xb4de,
47016d8656Alexander Pyhalov0xf4b4, 0xb5aa, 0xf4b5, 0xb5af, 0xb5c4, 0xb5e8, 0xf4b6, 0xb7c2,
47116d8656Alexander Pyhalov0xb7e4, 0xb7e8, 0xb7e7, 0xf4b7, 0xf4b8, 0xf4b9, 0xb8ce, 0xb8e1,
47216d8656Alexander Pyhalov0xb8f5, 0xb8f7, 0xb8f8, 0xb8fc, 0xb9af, 0xb9b7, 0xbabe, 0xbadb,
47316d8656Alexander Pyhalov0xcdaa, 0xbae1, 0xf4ba, 0xbaeb, 0xbbb3, 0xbbb8, 0xf4bb, 0xbbca,
47416d8656Alexander Pyhalov0xf4bc, 0xf4bd, 0xbbd0, 0xbbde, 0xbbf4, 0xbbf5, 0xbbf9, 0xbce4,
47516d8656Alexander Pyhalov0xbced, 0xbcfe, 0xf4be, 0xbdc2, 0xbde7, 0xf4bf, 0xbdf0, 0xbeb0,
47616d8656Alexander Pyhalov0xbeac, 0xf4c0, 0xbeb3, 0xbebd, 0xbecd, 0xbec9, 0xbee4, 0xbfa8,
47716d8656Alexander Pyhalov0xbfc9, 0xc0c4, 0xc0e4, 0xc0f4, 0xc1a6, 0xf4c1, 0xc1f5, 0xc1fc,
47816d8656Alexander Pyhalov0xf4c2, 0xc1f8, 0xc2ab, 0xc2a1, 0xc2a5, 0xf4c3, 0xc2b8, 0xc2ba,
47916d8656Alexander Pyhalov0xf4c4, 0xc2c4, 0xc2d2, 0xc2d7, 0xc2db, 0xc2de, 0xc2ed, 0xc2f0,
48016d8656Alexander Pyhalov0xf4c5, 0xc3a1, 0xc3b5, 0xc3c9, 0xc3b9, 0xf4c6, 0xc3d8, 0xc3fe,
48116d8656Alexander Pyhalov0xf4c7, 0xc4cc, 0xf4c8, 0xc4d9, 0xc4ea, 0xc4fd, 0xf4c9, 0xc5a7,
48216d8656Alexander Pyhalov0xc5b5, 0xc5b6, 0xf4ca, 0xc5d5, 0xc6b8, 0xc6d7, 0xc6e0, 0xc6ea,
48316d8656Alexander Pyhalov0xc6e3, 0xc7a1, 0xc7ab, 0xc7c7, 0xc7c3, 0xffff, 0xffff, 0xffff,
48416d8656Alexander Pyhalov0xc7cb, 0xc7cf, 0xc7d9, 0xf4cb, 0xf4cc, 0xc7e6, 0xc7ee, 0xc7fc, /* 0xfb47 */
48516d8656Alexander Pyhalov0xc7eb, 0xc7f0, 0xc8b1, 0xc8e5, 0xc8f8, 0xc9a6, 0xc9ab, 0xc9ad,
48616d8656Alexander Pyhalov0xf4cd, 0xc9ca, 0xc9d3, 0xc9e9, 0xc9e3, 0xc9fc, 0xc9f4, 0xc9f5,
48716d8656Alexander Pyhalov0xf4ce, 0xcab3, 0xcabd, 0xcaef, 0xcaf1, 0xcbae, 0xf4cf, 0xcbca,
48816d8656Alexander Pyhalov0xcbe6, 0xcbea, 0xcbf0, 0xcbf4, 0xcbee, 0xcca5, 0xcbf9, 0xccab,
48916d8656Alexander Pyhalov0xccae, 0xccad, 0xccb2, 0xccc2, 0xccd0, 0xccd9, 0xf4d0, 0xcdbb,
49016d8656Alexander Pyhalov0xf4d1, 0xcebb, 0xf4d2, 0xceba, 0xcec3, 0xf4d3, 0xcef2, 0xb3dd,
49116d8656Alexander Pyhalov0xcfd5, 0xcfe2, 0xcfe9, 0xcfed, 0xf4d4, 0xf4d5, 0xf4d6, 0xffff,
49216d8656Alexander Pyhalov0xf4d7, 0xd0e5, 0xf4d8, 0xd0e9, 0xd1e8, 0xf4d9, 0xf4da, 0xd1ec,
49316d8656Alexander Pyhalov0xd2bb, 0xf4db, 0xd3e1, 0xd3e8, 0xd4a7, 0xf4dc, 0xf4dd, 0xd4d4,
49416d8656Alexander Pyhalov0xd4f2, 0xd5ae, 0xf4de, 0xd7de, 0xf4df, 0xd8a2, 0xd8b7, 0xd8c1,
49516d8656Alexander Pyhalov0xd8d1, 0xd8f4, 0xd9c6, 0xd9c8, 0xd9d1, 0xf4e0, 0xf4e1, 0xf4e2,
49616d8656Alexander Pyhalov0xf4e3, 0xf4e4, 0xdcd3, 0xddc8, 0xddd4, 0xddea, 0xddfa, 0xdea4,
49716d8656Alexander Pyhalov0xdeb0, 0xf4e5, 0xdeb5, 0xdecb, 0xf4e6, 0xdfb9, 0xf4e7, 0xdfc3,
49816d8656Alexander Pyhalov0xf4e8, 0xf4e9, 0xe0d9, 0xf4ea, 0xf4eb, 0xe1e2, 0xf4ec, 0xf4ed,
49916d8656Alexander Pyhalov0xf4ee, 0xe2c7, 0xe3a8, 0xe3a6, 0xe3a9, 0xe3af, 0xe3b0, 0xe3aa,
50016d8656Alexander Pyhalov0xe3ab, 0xe3bc, 0xe3c1, 0xe3bf, 0xe3d5, 0xe3d8, 0xe3d6, 0xe3df,
50116d8656Alexander Pyhalov0xe3e3, 0xe3e1, 0xe3d4, 0xe3e9, 0xe4a6, 0xe3f1, 0xe3f2, 0xe4cb,
50216d8656Alexander Pyhalov0xe4c1, 0xe4c3, 0xe4be, 0xf4ef, 0xe4c0, 0xe4c7, 0xe4bf, 0xe4e0,
50316d8656Alexander Pyhalov0xe4de, 0xe4d1, 0xf4f0, 0xe4dc, 0xe4d2, 0xe4db, 0xe4d4, 0xe4fa,
50416d8656Alexander Pyhalov0xe4ef, 0xe5b3, 0xe5bf, 0xe5c9, 0xe5d0, 0xe5e2, 0xe5ea, 0xe5eb,
50516d8656Alexander Pyhalov0xf4f1, 0xf4f2, 0xf4f3, 0xe6e8, 0xe6ef, 0xe7ac, 0xf4f4, 0xe7ae,
50616d8656Alexander Pyhalov0xf4f5, 0xe7b1, 0xf4f6, 0xe7b2, 0xe8b1, 0xe8b6, 0xf4f7, 0xf4f8,
50716d8656Alexander Pyhalov0xe8dd, 0xf4f9, 0xf4fa, 0xe9d1, 0xf4fb, 0xffff, 0xffff, 0xffff,
50816d8656Alexander Pyhalov0xe9ed, 0xeacd, 0xf4fc, 0xeadb, 0xeae6, 0xeaea, 0xeba5, 0xebfb, /* 0xfc47 */
50916d8656Alexander Pyhalov0xebfa, 0xf4fd, 0xecd6, 0xf4fe, 0xffff, 0xffff, 0xffff, 0xffff,
51016d8656Alexander Pyhalov0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
51116d8656Alexander Pyhalov0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
51216d8656Alexander Pyhalov0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
51316d8656Alexander Pyhalov0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
51416d8656Alexander Pyhalov0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
51516d8656Alexander Pyhalov0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
51616d8656Alexander Pyhalov0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
51716d8656Alexander Pyhalov0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
51816d8656Alexander Pyhalov0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
51916d8656Alexander Pyhalov0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
52016d8656Alexander Pyhalov0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
52116d8656Alexander Pyhalov0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
52216d8656Alexander Pyhalov0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
52316d8656Alexander Pyhalov0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
52416d8656Alexander Pyhalov0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
52516d8656Alexander Pyhalov0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
52616d8656Alexander Pyhalov0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
52716d8656Alexander Pyhalov0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
52816d8656Alexander Pyhalov0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
52916d8656Alexander Pyhalov0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
53016d8656Alexander Pyhalov0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
53116d8656Alexander Pyhalov0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff
53216d8656Alexander Pyhalov};
53316d8656Alexander Pyhalov/*
53416d8656Alexander Pyhalov * jis208tosj1[]:
53516d8656Alexander Pyhalov * Directly convert 1st octet of JISX0208 encoded 2bytes codes
53616d8656Alexander Pyhalov * to the 1st octet of Shift-JIS encoded 2bytes codes.
53716d8656Alexander Pyhalov * Because the 8th bit is always OFF, the size of this array
53816d8656Alexander Pyhalov * can be limited to 128. (Precisely, 1st octet can vary between
53916d8656Alexander Pyhalov * 0x21 and 0x7e, and the correspondent Shift-JIS code is
54016d8656Alexander Pyhalov * between 0x81 and 0xfc. So we can use "0xff" as indicating invalid
54116d8656Alexander Pyhalov * value.)
54216d8656Alexander Pyhalov *
54316d8656Alexander Pyhalov * Principal:
54416d8656Alexander Pyhalov * 1: Index the array by using the value above as index number.
54516d8656Alexander Pyhalov * 2: Value "0xff" means the index number is invalid or, there's
54616d8656Alexander Pyhalov *    no Shift-JIS value that corresponds to.
54716d8656Alexander Pyhalov *
54816d8656Alexander Pyhalov * Note:
54916d8656Alexander Pyhalov * 1: Some of Shift-JIS code points are mapped to JISX0208 plane
55016d8656Alexander Pyhalov *    and others to JISX0212 plane.
55116d8656Alexander Pyhalov *    Need to differentiate them before indexing and designate
55216d8656Alexander Pyhalov *    appropriate character set. This table converts only code points
55316d8656Alexander Pyhalov *    within each character set.
55416d8656Alexander Pyhalov *
55516d8656Alexander Pyhalov */
55616d8656Alexander Pyhalovstatic const unsigned char jis208tosj1[] = {
55716d8656Alexander Pyhalov/* Values never be indexed */
55816d8656Alexander Pyhalov0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
55916d8656Alexander Pyhalov0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
56016d8656Alexander Pyhalov0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
56116d8656Alexander Pyhalov0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
56216d8656Alexander Pyhalov0xff,
56316d8656Alexander Pyhalov/* Index 1KU - 62KU in JISX0208 */
56416d8656Alexander Pyhalov      0x81, 0x81, 0x82, 0x82, 0x83, 0x83, 0x84,
56516d8656Alexander Pyhalov0x84, 0x85, 0x85, 0x86, 0x86, 0x87, 0x87, 0x88,
56616d8656Alexander Pyhalov0x88, 0x89, 0x89, 0x8a, 0x8a, 0x8b, 0x8b, 0x8c,
56716d8656Alexander Pyhalov0x8c, 0x8d, 0x8d, 0x8e, 0x8e, 0x8f, 0x8f, 0x90,
56816d8656Alexander Pyhalov0x90, 0x91, 0x91, 0x92, 0x92, 0x93, 0x93, 0x94,
56916d8656Alexander Pyhalov0x94, 0x95, 0x95, 0x96, 0x96, 0x97, 0x97, 0x98,
57016d8656Alexander Pyhalov0x98, 0x99, 0x99, 0x9a, 0x9a, 0x9b, 0x9b, 0x9c,
57116d8656Alexander Pyhalov0x9c, 0x9d, 0x9d, 0x9e, 0x9e, 0x9f, 0x9f,
57216d8656Alexander Pyhalov/* Index 63KU - 84KU in JISX0208 */
57316d8656Alexander Pyhalov                                          0xe0,
57416d8656Alexander Pyhalov0xe0, 0xe1, 0xe1, 0xe2, 0xe2, 0xe3, 0xe3, 0xe4,
57516d8656Alexander Pyhalov0xe4, 0xe5, 0xe5, 0xe6, 0xe6, 0xe7, 0xe7, 0xe8,
57616d8656Alexander Pyhalov0xe8, 0xe9, 0xe9, 0xea, 0xea,
57716d8656Alexander Pyhalov/* Followings are mapped to "UDC" area in Shift-JIS */
57816d8656Alexander Pyhalov                              0xf0, 0xf0, 0xf1,
57916d8656Alexander Pyhalov0xf1, 0xf2, 0xf2, 0xf3, 0xf3, 0xf4, 0xf4,
58016d8656Alexander Pyhalov/* Values never be indexed */
58116d8656Alexander Pyhalov0xff
58216d8656Alexander Pyhalov};
58316d8656Alexander Pyhalov
58416d8656Alexander Pyhalov/*
58516d8656Alexander Pyhalov * jis212tosj1[]:
58616d8656Alexander Pyhalov * Directly convert 1st octet of JISX0212 encoded 2bytes codes
58716d8656Alexander Pyhalov * to the 1st octet of Shift-JIS encoded 2bytes codes.
58816d8656Alexander Pyhalov * Because the 8th bit is always OFF, the size of this array
58916d8656Alexander Pyhalov * can be limited to 128. (Precisely, 1st octet can vary between
59016d8656Alexander Pyhalov * 0x21 and 0x7e, and the correspondent Shift-JIS code is
59116d8656Alexander Pyhalov * between 0x81 and 0xfc. So we can use "0xff" as indicating invalid
59216d8656Alexander Pyhalov * value.)
59316d8656Alexander Pyhalov *
59416d8656Alexander Pyhalov * Principal:
59516d8656Alexander Pyhalov * 1: Index the array by using the value above as index number.
59616d8656Alexander Pyhalov * 2: Value "0xff" means the index number is invalid or, there's
59716d8656Alexander Pyhalov *    no Shift-JIS value that corresponds to.
59816d8656Alexander Pyhalov *
59916d8656Alexander Pyhalov * Note:
60016d8656Alexander Pyhalov * 1: Most G3 characters cannot map to Shift-JIS coded space.
60116d8656Alexander Pyhalov *    (Such characters are mapped to unique code point. In this
60216d8656Alexander Pyhalov *    table, it is 0x222e in JISX0208.)
60316d8656Alexander Pyhalov * 2: Some of Shift-JIS code points are mapped to JISX0208 plane
60416d8656Alexander Pyhalov *    and others to JISX0212 plane.
60516d8656Alexander Pyhalov *    Need to differentiate them before indexing and designate
60616d8656Alexander Pyhalov *    appropriate character set. This table converts only code points
60716d8656Alexander Pyhalov *    within each character set.
60816d8656Alexander Pyhalov *
60916d8656Alexander Pyhalov */
61016d8656Alexander Pyhalovstatic const unsigned char jis212tosj1[] = {
61116d8656Alexander Pyhalov/* Values never be indexed */
61216d8656Alexander Pyhalov0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
61316d8656Alexander Pyhalov0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
61416d8656Alexander Pyhalov0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
61516d8656Alexander Pyhalov0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
61616d8656Alexander Pyhalov0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
61716d8656Alexander Pyhalov0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
61816d8656Alexander Pyhalov0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
61916d8656Alexander Pyhalov0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
62016d8656Alexander Pyhalov0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
62116d8656Alexander Pyhalov0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
62216d8656Alexander Pyhalov0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
62316d8656Alexander Pyhalov0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
62416d8656Alexander Pyhalov0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
62516d8656Alexander Pyhalov0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
62616d8656Alexander Pyhalov/* Followings are mapped to "NEC/IBM(?)" area in Shift-JIS */
62716d8656Alexander Pyhalov/*                                          0xfa,	*/
62816d8656Alexander Pyhalov/* 0xfa, 0xfb, 0xfb, 0xfc, 0xfc,			*/
62916d8656Alexander Pyhalov                                          0xff,
63016d8656Alexander Pyhalov0xff, 0xff, 0xff, 0xff, 0xff,
63116d8656Alexander Pyhalov/* Followings are mapped to "UDC" area in Shift-JIS */
63216d8656Alexander Pyhalov                              0xf5, 0xf5, 0xf6,
63316d8656Alexander Pyhalov0xf6, 0xf7, 0xf7, 0xf8, 0xf8, 0xf9, 0xf9,
63416d8656Alexander Pyhalov/* Values never be indexed */
63516d8656Alexander Pyhalov0xff
63616d8656Alexander Pyhalov};
63716d8656Alexander Pyhalov
63816d8656Alexander Pyhalov/*
63916d8656Alexander Pyhalov * jistosj2[]:
64016d8656Alexander Pyhalov * Directly convert 2nd octet of 7bit-JIS encoded 2bytes codes
64116d8656Alexander Pyhalov * to the 2nd octet of Shift-JIS encoded 2bytes codes.
64216d8656Alexander Pyhalov * Although the source code may have the same value between
64316d8656Alexander Pyhalov * JISX0208 and JISX0212, the destination code point can vary with regard to
64416d8656Alexander Pyhalov * the eveness(oddness) of 'KU' number.
64516d8656Alexander Pyhalov *
64616d8656Alexander Pyhalov * Principal:
64716d8656Alexander Pyhalov * 1: Add 0x80 if 'KU' number is even.
64816d8656Alexander Pyhalov * 2: Index the array by using the value above as index number.
64916d8656Alexander Pyhalov * 3: Value "0xff" means the index number is invalid or, there's
65016d8656Alexander Pyhalov *    no Shift-JIS value that corresponds to.
65116d8656Alexander Pyhalov *
65216d8656Alexander Pyhalov * Note:
65316d8656Alexander Pyhalov * 1: Use this table to map the 2nd octet of both JISX0208
65416d8656Alexander Pyhalov *    and JISX0212.
65516d8656Alexander Pyhalov *
65616d8656Alexander Pyhalov */
65716d8656Alexander Pyhalovstatic const unsigned char jistosj2[] = {
65816d8656Alexander Pyhalov/* Values never be indexed */
65916d8656Alexander Pyhalov0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
66016d8656Alexander Pyhalov0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
66116d8656Alexander Pyhalov0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
66216d8656Alexander Pyhalov0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
66316d8656Alexander Pyhalov0xff,
66416d8656Alexander Pyhalov/* Index 1TEN - 63TEN in 'odd KU' */
66516d8656Alexander Pyhalov      0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46,
66616d8656Alexander Pyhalov0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e,
66716d8656Alexander Pyhalov0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56,
66816d8656Alexander Pyhalov0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e,
66916d8656Alexander Pyhalov0x5f, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
67016d8656Alexander Pyhalov0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e,
67116d8656Alexander Pyhalov0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76,
67216d8656Alexander Pyhalov0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e,
67316d8656Alexander Pyhalov/* Index 64TEN - 94TEN in 'odd KU' */
67416d8656Alexander Pyhalov0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
67516d8656Alexander Pyhalov0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
67616d8656Alexander Pyhalov0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
67716d8656Alexander Pyhalov0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e,
67816d8656Alexander Pyhalov/* Values never be indexed */
67916d8656Alexander Pyhalov                                          0xff,
68016d8656Alexander Pyhalov0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
68116d8656Alexander Pyhalov0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
68216d8656Alexander Pyhalov0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
68316d8656Alexander Pyhalov0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
68416d8656Alexander Pyhalov0xff,
68516d8656Alexander Pyhalov/* Index 1TEN - 63TEN in 'even KU' */
68616d8656Alexander Pyhalov      0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5,
68716d8656Alexander Pyhalov0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad,
68816d8656Alexander Pyhalov0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5,
68916d8656Alexander Pyhalov0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd,
69016d8656Alexander Pyhalov0xbe, 0xbf, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5,
69116d8656Alexander Pyhalov0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd,
69216d8656Alexander Pyhalov0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5,
69316d8656Alexander Pyhalov0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd,
69416d8656Alexander Pyhalov0xde, 0xdf, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5,
69516d8656Alexander Pyhalov0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed,
69616d8656Alexander Pyhalov0xee, 0xef, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5,
69716d8656Alexander Pyhalov0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc,
69816d8656Alexander Pyhalov/* Values never be indexed */
69916d8656Alexander Pyhalov0xff
70016d8656Alexander Pyhalov};
70116d8656Alexander Pyhalov
70216d8656Alexander Pyhalov#define	JGETA	(0x222e)
70316d8656Alexander Pyhalov#define	EGETA	(0xa2ae)
70416d8656Alexander Pyhalov#define	PGETA	(0x81ac)
70516d8656Alexander Pyhalov
70616d8656Alexander Pyhalov/*
70716d8656Alexander Pyhalov * Remap NEC/IBM codes to IBM codes
70816d8656Alexander Pyhalov * if dest == 0xffff, that means the source
70916d8656Alexander Pyhalov * code point is illegal in the current spec.
71016d8656Alexander Pyhalov */
71116d8656Alexander Pyhalov
71216d8656Alexander Pyhalov #define REMAP_NEC(dest) \
71316d8656Alexander Pyhalov	if ((0xed40 <= dest) && \
71416d8656Alexander Pyhalov		(dest <= 0xed62)) { \
71516d8656Alexander Pyhalov		dest += 0xd1c; \
71616d8656Alexander Pyhalov	} else if ((0xed63 <= dest) && \
71716d8656Alexander Pyhalov		(dest <= 0xed7e)) { \
71816d8656Alexander Pyhalov		dest += 0xd1d; \
71916d8656Alexander Pyhalov	} else if ((0xed80 <= dest) && \
72016d8656Alexander Pyhalov		(dest <= 0xede0)) { \
72116d8656Alexander Pyhalov		dest += 0xd1c; \
72216d8656Alexander Pyhalov	} else if ((0xede1 <= dest) && \
72316d8656Alexander Pyhalov		(dest <= 0xedfc)) { \
72416d8656Alexander Pyhalov		dest += 0xd5f; \
72516d8656Alexander Pyhalov	} else if ((0xee40 <= dest) && \
72616d8656Alexander Pyhalov		(dest <= 0xee62)) { \
72716d8656Alexander Pyhalov		dest += 0xd1c; \
72816d8656Alexander Pyhalov	} else if ((0xee63 <= dest) && \
72916d8656Alexander Pyhalov		(dest <= 0xee7e)) { \
73016d8656Alexander Pyhalov		dest += 0xd1d; \
73116d8656Alexander Pyhalov	} else if ((0xee80 <= dest) && \
73216d8656Alexander Pyhalov		(dest <= 0xeee0)) { \
73316d8656Alexander Pyhalov		dest += 0xd1c; \
73416d8656Alexander Pyhalov	} else if ((0xeee1 <= dest) && \
73516d8656Alexander Pyhalov		(dest <= 0xeeec)) { \
73616d8656Alexander Pyhalov		dest += 0xd5f; \
73716d8656Alexander Pyhalov	} else if ((0xeeef <= dest) && \
73816d8656Alexander Pyhalov		(dest <= 0xeef8)) { \
73916d8656Alexander Pyhalov		dest += 0xb51; \
74016d8656Alexander Pyhalov	} else if ((0xeef9 <= dest) && \
74116d8656Alexander Pyhalov		(dest <= 0xeefc)) { \
74216d8656Alexander Pyhalov		dest += 0xb5b; \
74316d8656Alexander Pyhalov	} else { \
74416d8656Alexander Pyhalov		dest = 0xffff; \
74516d8656Alexander Pyhalov	}
74616d8656Alexander Pyhalov
74716d8656Alexander Pyhalov#define CHECK2BIG(width,time) \
74816d8656Alexander Pyhalov	if (oleft < (width)) { \
74916d8656Alexander Pyhalov		int i; \
75016d8656Alexander Pyhalov		for (i = time; i > 0; i--) { \
75116d8656Alexander Pyhalov			UNGET(); \
75216d8656Alexander Pyhalov		} \
75316d8656Alexander Pyhalov		errno = E2BIG; \
75416d8656Alexander Pyhalov		retval = (size_t)ERR_RETURN; \
75516d8656Alexander Pyhalov		goto ret; \
75616d8656Alexander Pyhalov	}
75716d8656Alexander Pyhalov
75816d8656Alexander Pyhalov/*
75916d8656Alexander Pyhalov * halfkana2zenkakuj[]:
76016d8656Alexander Pyhalov * Directly convert JIS X 0201 Kana (half width) to JIS X 0208
76116d8656Alexander Pyhalov * Kana (full width).
76216d8656Alexander Pyhalov * This table is for ISO-2022-JP.RFC1468 mode.
76316d8656Alexander Pyhalov *
76416d8656Alexander Pyhalov * Principal:
76516d8656Alexander Pyhalov * 1: Subtract 0x21 or 0x81.
76616d8656Alexander Pyhalov * 2: Index the array by using the value above as index number.
76716d8656Alexander Pyhalov *
76816d8656Alexander Pyhalov * Note:
76916d8656Alexander Pyhalov */
77016d8656Alexander Pyhalovstatic const unsigned short halfkana2zenkakuj[] = {
77116d8656Alexander Pyhalov0x2123, 0x2156, 0x2157, 0x2122, 0x2126, 0x2572, 0x2521, 0x2523,
77216d8656Alexander Pyhalov0x2525, 0x2527, 0x2529, 0x2563, 0x2565, 0x2567, 0x2543, 0x213c,
77316d8656Alexander Pyhalov0x2522, 0x2524, 0x2526, 0x2528, 0x252a, 0x252b, 0x252d, 0x252f,
77416d8656Alexander Pyhalov0x2531, 0x2533, 0x2535, 0x2537, 0x2539, 0x253b, 0x253d, 0x253f,
77516d8656Alexander Pyhalov0x2541, 0x2544, 0x2546, 0x2548, 0x254a, 0x254b, 0x254c, 0x254d,
77616d8656Alexander Pyhalov0x254e, 0x254f, 0x2552, 0x2555, 0x2558, 0x255b, 0x255e, 0x255f,
77716d8656Alexander Pyhalov0x2560, 0x2561, 0x2562, 0x2564, 0x2566, 0x2568, 0x2569, 0x256a,
77816d8656Alexander Pyhalov0x256b, 0x256c, 0x256d, 0x256f, 0x2573, 0x212b, 0x212c};
77916d8656Alexander Pyhalov
78016d8656Alexander Pyhalov/*
78116d8656Alexander Pyhalov * halfkana2zenkakue[]:
78216d8656Alexander Pyhalov * Directly convert JIS X 0201 Kana (half width) to JIS X 0208
78316d8656Alexander Pyhalov * (eucJP).
78416d8656Alexander Pyhalov * This table is for ISO-2022-JP.RFC1468 mode.
78516d8656Alexander Pyhalov *
78616d8656Alexander Pyhalov * Principal:
78716d8656Alexander Pyhalov * 1: Subtract 0x21 or 0x81.
78816d8656Alexander Pyhalov * 2: Index the array by using the value above as index number.
78916d8656Alexander Pyhalov *
79016d8656Alexander Pyhalov * Note:
79116d8656Alexander Pyhalov */
79216d8656Alexander Pyhalovstatic const unsigned short halfkana2zenkakue[] = {
79316d8656Alexander Pyhalov0xa1a3, 0xa1d6, 0xa1d7, 0xa1a2, 0xa1a6, 0xa5f2, 0xa5a1,
79416d8656Alexander Pyhalov0xa5a3, 0xa5a5, 0xa5a7, 0xa5a9, 0xa5e3, 0xa5e5, 0xa5e7,
79516d8656Alexander Pyhalov0xa5c3, 0xa1bc, 0xa5a2, 0xa5a4, 0xa5a6, 0xa5a8, 0xa5aa,
79616d8656Alexander Pyhalov0xa5ab, 0xa5ad, 0xa5af, 0xa5b1, 0xa5b3, 0xa5b5, 0xa5b7,
79716d8656Alexander Pyhalov0xa5b9, 0xa5bb, 0xa5bd, 0xa5bf, 0xa5c1, 0xa5c4, 0xa5c6,
79816d8656Alexander Pyhalov0xa5c8, 0xa5ca, 0xa5cb, 0xa5cc, 0xa5cd, 0xa5ce, 0xa5cf,
79916d8656Alexander Pyhalov0xa5d2, 0xa5d5, 0xa5d8, 0xa5db, 0xa5de, 0xa5df, 0xa5e0,
80016d8656Alexander Pyhalov0xa5e1, 0xa5e2, 0xa5e4, 0xa5e6, 0xa5e8, 0xa5e9, 0xa5ea,
80116d8656Alexander Pyhalov0xa5eb, 0xa5ec, 0xa5ed, 0xa5ef, 0xa5f3, 0xa1ab, 0xa1ac};
80216d8656Alexander Pyhalov
80316d8656Alexander Pyhalov/*
80416d8656Alexander Pyhalov * halfkana2zenkakus[]:
80516d8656Alexander Pyhalov * Directly convert JIS X 0201 Kana (half width) to PCK Kana
80616d8656Alexander Pyhalov * (full width).
80716d8656Alexander Pyhalov * This table is for ISO-2022-JP.RFC1468 mode.
80816d8656Alexander Pyhalov *
80916d8656Alexander Pyhalov * Principal:
81016d8656Alexander Pyhalov * 1: Subtract 0x21 or 0x81.
81116d8656Alexander Pyhalov * 2: Index the array by using the value above as index number.
81216d8656Alexander Pyhalov *
81316d8656Alexander Pyhalov * Note:
81416d8656Alexander Pyhalov */
81516d8656Alexander Pyhalovstatic const unsigned short halfkana2zenkakus[] = {
81616d8656Alexander Pyhalov0x8142, 0x8175, 0x8176, 0x8141, 0x8145, 0x8392, 0x8340, 0x8342,
81716d8656Alexander Pyhalov0x8344, 0x8346, 0x8348, 0x8383, 0x8385, 0x8387, 0x8362, 0x815b,
81816d8656Alexander Pyhalov0x8341, 0x8343, 0x8345, 0x8347, 0x8349, 0x834a, 0x834c, 0x834e,
81916d8656Alexander Pyhalov0x8350, 0x8352, 0x8354, 0x8356, 0x8358, 0x835a, 0x835c, 0x835e,
82016d8656Alexander Pyhalov0x8360, 0x8363, 0x8365, 0x8367, 0x8369, 0x836a, 0x836b, 0x836c,
82116d8656Alexander Pyhalov0x836d, 0x836e, 0x8371, 0x8374, 0x8377, 0x837a, 0x837d, 0x837e,
82216d8656Alexander Pyhalov0x8380, 0x8381, 0x8382, 0x8384, 0x8386, 0x8388, 0x8389, 0x838a,
82316d8656Alexander Pyhalov0x838b, 0x838c, 0x838d, 0x838f, 0x8393, 0x814a, 0x814b};
824