xref: /titanic_50/usr/src/uts/common/sys/kiconv_tc.h (revision 15d9d0b528387242011cdcc6190c9e598cfe3a07)
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_TC_H
27 #define	_SYS_KICONV_TC_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 first BIG5 byte or not. */
38 #define	KICONV_TC_IS_BIG5_1st_BYTE(v)	((v) >= 0x81 && (v) <= 0xFE)
39 
40 /* Valid second BIG5 byte or not. */
41 #define	KICONV_TC_IS_BIG5_2nd_BYTE(v)				\
42 	    (((v) >= 0x40 && (v) <= 0x7E) || ((v) >= 0xA1 && (v) <= 0xFE))
43 
44 /* Start byte of CNS 11643 plane 2 - plane 16. */
45 #define	KICONV_TC_EUCTW_MBYTE		(0x8E)
46 
47 /* Plane number mask of CNS 11643 */
48 #define	KICONV_TC_EUCTW_PMASK		(0xA0)
49 
50 /* Valid first byte of CNS 11643 1-16 plane character or not. */
51 #define	KICONV_TC_IS_EUCTW_1st_BYTE(v)				\
52 		((v) == KICONV_TC_EUCTW_MBYTE || KICONV_IS_VALID_EUC_BYTE(v))
53 
54 /* Valid EUC-TW sequence or not. */
55 #define	KICONV_TC_IS_VALID_EUCTW_SEQ(ib)				\
56 	    ((isplane1 && (KICONV_IS_VALID_EUC_BYTE(*((ib) + 1)))) ||	\
57 	    (plane_no <= 16 && plane_no >= 2 && 			\
58 	    KICONV_IS_VALID_EUC_BYTE(*((ib) + 2)) &&			\
59 	    KICONV_IS_VALID_EUC_BYTE(*((ib) + 3))))
60 
61 /*
62  * Plane 12/13/14/16 of EUC-TW fall in UDA range [U+F0000, U+F8A0F] in
63  * Unicode.
64  */
65 #define	KICONV_TC_UDA_UCS4_START	(0xF0000)
66 #define	KICONV_TC_UDA_UTF8_START	(0xF3B08080)
67 #define	KICONV_TC_UDA_UTF8_END		(0xF3B8A88F)
68 
69 #endif	/* _KERNEL */
70 
71 #ifdef __cplusplus
72 }
73 #endif
74 
75 #endif /* _SYS_KICONV_TC_H */
76