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