xref: /titanic_51/usr/src/uts/common/sys/kiconv_ko.h (revision 15d9d0b528387242011cdcc6190c9e598cfe3a07)
1*15d9d0b5Syy154373 /*
2*15d9d0b5Syy154373  * CDDL HEADER START
3*15d9d0b5Syy154373  *
4*15d9d0b5Syy154373  * The contents of this file are subject to the terms of the
5*15d9d0b5Syy154373  * Common Development and Distribution License (the "License").
6*15d9d0b5Syy154373  * You may not use this file except in compliance with the License.
7*15d9d0b5Syy154373  *
8*15d9d0b5Syy154373  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*15d9d0b5Syy154373  * or http://www.opensolaris.org/os/licensing.
10*15d9d0b5Syy154373  * See the License for the specific language governing permissions
11*15d9d0b5Syy154373  * and limitations under the License.
12*15d9d0b5Syy154373  *
13*15d9d0b5Syy154373  * When distributing Covered Code, include this CDDL HEADER in each
14*15d9d0b5Syy154373  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*15d9d0b5Syy154373  * If applicable, add the following below this CDDL HEADER, with the
16*15d9d0b5Syy154373  * fields enclosed by brackets "[]" replaced with your own identifying
17*15d9d0b5Syy154373  * information: Portions Copyright [yyyy] [name of copyright owner]
18*15d9d0b5Syy154373  *
19*15d9d0b5Syy154373  * CDDL HEADER END
20*15d9d0b5Syy154373  */
21*15d9d0b5Syy154373 /*
22*15d9d0b5Syy154373  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23*15d9d0b5Syy154373  * Use is subject to license terms.
24*15d9d0b5Syy154373  */
25*15d9d0b5Syy154373 
26*15d9d0b5Syy154373 #ifndef _SYS_KICONV_KO_H
27*15d9d0b5Syy154373 #define	_SYS_KICONV_KO_H
28*15d9d0b5Syy154373 
29*15d9d0b5Syy154373 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30*15d9d0b5Syy154373 
31*15d9d0b5Syy154373 #ifdef __cplusplus
32*15d9d0b5Syy154373 extern "C" {
33*15d9d0b5Syy154373 #endif
34*15d9d0b5Syy154373 
35*15d9d0b5Syy154373 #ifdef	_KERNEL
36*15d9d0b5Syy154373 
37*15d9d0b5Syy154373 /* Valid EUC-KR byte or not. */
38*15d9d0b5Syy154373 #define	KICONV_KO_IS_EUCKR_BYTE(b)	((b) >= 0xA1 && (b) <= 0xFE)
39*15d9d0b5Syy154373 
40*15d9d0b5Syy154373 /* Valid UHC byte or not. */
41*15d9d0b5Syy154373 #define	KICONV_KO_IS_UHC_1st_BYTE(b)	((b) >= 0x81 && (b) <= 0xFE)
42*15d9d0b5Syy154373 #define	KICONV_KO_IS_UHC_2nd_BYTE(b)					\
43*15d9d0b5Syy154373 		    ((b) >= 0x41 && (b) <= 0x5A ||			\
44*15d9d0b5Syy154373 		    (b) >= 0x61 && (b) <= 0x7A ||			\
45*15d9d0b5Syy154373 		    (b) >= 0x81 && (b) <= 0xFE)
46*15d9d0b5Syy154373 
47*15d9d0b5Syy154373 /* UDA range in EUC-KR: row 41 and 94 of KS C 5601-1987. */
48*15d9d0b5Syy154373 #define	KICONV_KO_UDA_EUC_SEG1_START	(0xC9A1)
49*15d9d0b5Syy154373 #define	KICONV_KO_UDA_EUC_SEG1_END	(0xC9FE)
50*15d9d0b5Syy154373 #define	KICONV_KO_UDA_EUC_SEG2_START	(0xFEA1)
51*15d9d0b5Syy154373 #define	KICONV_KO_UDA_EUC_SEG2_END	(0xFEFE)
52*15d9d0b5Syy154373 #define	KICONV_KO_UDA_EUC_SEG1		(0xC9)
53*15d9d0b5Syy154373 #define	KICONV_KO_UDA_EUC_SEG2		(0xFE)
54*15d9d0b5Syy154373 #define	KICONV_KO_UDA_OFFSET_START	(0xA1)
55*15d9d0b5Syy154373 #define	KICONV_KO_UDA_OFFSET_END	(0xFE)
56*15d9d0b5Syy154373 #define	KICONV_KO_UDA_RANGE		(0x5E)		/* 0xFE - 0xA1 + 1 */
57*15d9d0b5Syy154373 #define	KICONV_KO_UDA_OFFSET_1		(0xF65F)	/* 0xF700 - 0xA1 */
58*15d9d0b5Syy154373 #define	KICONV_KO_UDA_OFFSET_2		(0xF6BD)	/* 0xF65F + 0x5E */
59*15d9d0b5Syy154373 
60*15d9d0b5Syy154373 /* EUC-KR UDA range in Unicode. */
61*15d9d0b5Syy154373 #define	KICONV_KO_UDA_UCS4_START	(0xF700)
62*15d9d0b5Syy154373 #define	KICONV_KO_UDA_UCS4_END		(0xF7BB)
63*15d9d0b5Syy154373 #define	KICONV_KO_UDA_UTF8_START	(0xEF9C80)
64*15d9d0b5Syy154373 #define	KICONV_KO_UDA_UTF8_END		(0xEF9EBB)
65*15d9d0b5Syy154373 
66*15d9d0b5Syy154373 /* Whether EUC character is UDC or not. */
67*15d9d0b5Syy154373 #define	KICONV_KO_IS_UDC_IN_EUC(v)				\
68*15d9d0b5Syy154373 	    (((v) >= KICONV_KO_UDA_EUC_SEG1_START &&		\
69*15d9d0b5Syy154373 	    (v) <= KICONV_KO_UDA_EUC_SEG1_END) ||		\
70*15d9d0b5Syy154373 	    ((v) >= KICONV_KO_UDA_EUC_SEG2_START &&		\
71*15d9d0b5Syy154373 	    (v) <= KICONV_KO_UDA_EUC_SEG2_END))
72*15d9d0b5Syy154373 
73*15d9d0b5Syy154373 /* Whether UTF-8 character is UDC or not. */
74*15d9d0b5Syy154373 #define	KICONV_KO_IS_UDC_IN_UTF8(v)				\
75*15d9d0b5Syy154373 	    ((v) >= KICONV_KO_UDA_UTF8_START &&			\
76*15d9d0b5Syy154373 	    (v) <= KICONV_KO_UDA_UTF8_END)
77*15d9d0b5Syy154373 
78*15d9d0b5Syy154373 #endif	/* _KERNEL */
79*15d9d0b5Syy154373 
80*15d9d0b5Syy154373 #ifdef __cplusplus
81*15d9d0b5Syy154373 }
82*15d9d0b5Syy154373 #endif
83*15d9d0b5Syy154373 
84*15d9d0b5Syy154373 #endif /* _SYS_KICONV_KO_H */
85