xref: /titanic_50/usr/src/lib/iconv_modules/euro/utils/japanese.h (revision 24bb1048b1197ebc9afe761e4098573aeedfe8c9)
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 (c) 1991, Sun Microsystems, Inc.
23  * Copyright (c) 1991, Nihon Sun Microsystems K.K.
24  */
25 
26 #define GET(c)		((c) = *ip, ip++, ileft--)
27 #define PUT(c)		(*op = (c), op++, oleft--)
28 #define UNGET()		(ip--, ileft++)
29 
30 #define ERR_RETURN	(-1)		/* result code on error */
31 
32 /* is a valid character for ascii? */
33 #define ISASC(c)		(((c) >= 0x00) && ((c) <= 0x7f))
34 
35 /* is a valid character for codeset 1? */
36 #define ISCS1(c)		(((c) >= 0xa1) && ((c) <= 0xfe))
37 
38 /* is a valid character for codeset 2? */
39 #define ISCS2(c)		(((c) >= 0xa1) && ((c) <= 0xdf))
40 
41 /* is a valid character for codeset 3? */
42 #define ISCS3(c)		(((c) >= 0xa1) && ((c) <= 0xfe))
43 
44 /* is a valid hankaku_katakana for SJIS? */
45 #define ISSJKANA(c)		(((c) >= 0xa1) && ((c) <= 0xdf))
46 
47 /* is a valid character for the first byte of SJIS kanji? */
48 #define ISSJKANJI1(c)	((((c) >= 0x81) && ((c) <= 0x9f)) ||\
49 						 (((c) >= 0xe0) && ((c) <= 0xef)))
50 
51 /* is a valid character for the second byte of SJIS kanji? */
52 #define ISSJKANJI2(c)	((((c) >= 0x40) && ((c) <= 0x7e)) ||\
53 						 (((c) >= 0x80) && ((c) <= 0xfc)))
54 
55 #define CS_0			0		/* codeset 0 */
56 #define CS_1			1		/* codeset 1 */
57 #define CS_2			2		/* codeset 2 */
58 #define CS_3			3		/* codeset 3 */
59 
60 #define ST_INIT			0		/* init */
61 #define ST_INCS1		1		/* in codeset 1 */
62 #define ST_INCS2		2		/* in codeset 2 */
63 #define ST_INCS3		3		/* in codeset 3 */
64 #define ST_ESC			4		/* in ESC */
65 #define ST_MBTOG0_1		5		/* in the designation of MB to G0 - 1 */
66 #define ST_MBTOG0_2		6		/* in the designation of MB to G0 - 2 */
67 #define ST_SBTOG0		7		/* in the designation of SB to G0 */
68 
69 /*
70  * CODE SET 0
71  * ESC ( B   			: To ASCII
72  * ESC ( J				: To JIS X 0201 - 1976 ROMAN
73  * ESC ( @				: TO ISO 646 IRV
74  *
75  * CODE SET 1
76  * ESC & @ ESC $ ( B	: To JIS X 0208 - 1990		: Not implemented
77  * ESC $ ( B			: To JIS X 0208 - 1983/1990
78  * ESC $ ( @			: To JIS X 0208 - 1978
79  * ESC $ B				: To JIS X 0208 - 1983/1990
80  * ESC $ @				: To JIS X 0208 - 1978
81  * ESC & @ ESC $ B		: To JIS X 0208 - 1983/1990	: Not implemented
82  *
83  * CODE SET 2
84  * SO  					: G1 -> G
85  * SI  					: G0 -> G
86  * ESC ( I				: To JIS X 0201 - 1976 Katakana
87  *
88  * CODE SET 3
89  * ESC $ ( D			: To JIS X 0212 - 1990
90  * ESC $ D				: To JIS X 0212 - 1990
91  *
92  */
93 
94 #define ESC					0x1b		/* Escape : 1/12 */
95 #define SO					0x0e		/* Shift Out : 0/14 */
96 #define SI					0x0f		/* SHift In  : 0/15 */
97 
98 #define SBTOG0_1			0x28		/* ( : 2/8 */
99 #define F_ASCII				0x42		/* B : 4/2 */
100 #define F_X0201_RM			0x4a		/* J : 4/10 */
101 #define F_ISO646			0x40		/* @ : 4/0 */
102 #define F_X0201_KN			0x49		/* I : 4/9 */
103 
104 #define MBTOG0_1			0x24		/* $ : 2/4 */
105 #define MBTOG0_2			0x28		/* ( : 2/8 */
106 #define F_X0208_83_90		0x42		/* B : 4/2 */
107 #define F_X0208_78			0x40		/* @ : 4/0 */
108 #define F_X0212_90			0x44		/* D : 4/4 */
109 
110 #define	CMASK				0x7f
111 #define	CMSB				0x80
112 
113 /* the byte length of ESC sequences */
114 #define SEQ_SBTOG0			3			/* ESC + ( + F */
115 #define SEQ_MBTOG0			4			/* ESC + $ + ( + F */
116 #define SEQ_MBTOG0_O		3			/* ESC + $ + F */
117 
118 /* the byte length of SO/SI */
119 #define SEQ_SOSI			1			/* SO or SI */
120 
121 /* the byte length of SS2/SS3 */
122 #define SEQ_SS				1			/* SS2 or SS3 */
123 
124 /* the byte length of JIS characters */
125 #define JISW0				1			/* ASCII */
126 #define JISW1				2			/* Kanji */
127 #define JISW2				1			/* Hankaku Katakana */
128 #define JISW3				2			/* Hojo Kanji */
129 
130 /* the byte length of EUC characters */
131 #define EUCW0				1			/* ASCII */
132 #define EUCW1				2			/* Kanji */
133 #define EUCW2				1			/* Hankaku Katakana */
134 #define EUCW3				2			/* Hojo Kanji */
135 #define SS2W				1			/* SS2 */
136 #define SS3W				1			/* SS3 */
137 
138 /* the byte length of SJIS characters */
139 #define SJISW0				1			/* ASCII */
140 #define SJISW1				2			/* Kanji */
141 #define SJISW2				1			/* Hankaku Katakana */
142 
143 #define EBCDIC0				1
144 #define EBCDIC1				2
145 #define EBCDIC2				1
146 #define EBCDIC3				2
147 
148 /* the byte length of unknown characters */
149 #define UNKNOWNW			1
150