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_SC_H 27*15d9d0b5Syy154373 #define _SYS_KICONV_SC_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 first byte of GB18030 character or not. */ 38*15d9d0b5Syy154373 #define KICONV_SC_IS_GBK_1st_BYTE(c) ((c) >= 0x81 && (c) <= 0xfe) 39*15d9d0b5Syy154373 40*15d9d0b5Syy154373 /* Valid 2nd byte of 2 bytes GB18030 character or not. */ 41*15d9d0b5Syy154373 #define KICONV_SC_IS_GBK_2nd_BYTE(c) \ 42*15d9d0b5Syy154373 (((c) >= 0x40 && (c) <= 0x7E) || ((c) >= 0x80 && (c) <= 0xFE)) 43*15d9d0b5Syy154373 44*15d9d0b5Syy154373 /* Valid 2nd byte of 4 bytes GB18030 character or not. */ 45*15d9d0b5Syy154373 #define KICONV_SC_IS_GB18030_2nd_BYTE(c) ((c) >= 0x30 && (c) <= 0x39) 46*15d9d0b5Syy154373 47*15d9d0b5Syy154373 /* Valid 3rd byte of 4 bytes GB18030 character or not. */ 48*15d9d0b5Syy154373 #define KICONV_SC_IS_GB18030_3rd_BYTE(c) ((c) >= 0x81 && (c) <= 0xfe) 49*15d9d0b5Syy154373 50*15d9d0b5Syy154373 /* Valid 4th byte of 4 bytes GB18030 character or not. */ 51*15d9d0b5Syy154373 #define KICONV_SC_IS_GB18030_4th_BYTE(c) \ 52*15d9d0b5Syy154373 KICONV_SC_IS_GB18030_2nd_BYTE((c)) 53*15d9d0b5Syy154373 54*15d9d0b5Syy154373 /* Get the number of bytes of one GB character(uint32_t). */ 55*15d9d0b5Syy154373 #define KICONV_SC_GET_GB_LEN(v, l) \ 56*15d9d0b5Syy154373 if (((v) & 0xFFFF0000) != 0) \ 57*15d9d0b5Syy154373 (l) = 4; \ 58*15d9d0b5Syy154373 else if (((v) & 0xFF00) != 0) \ 59*15d9d0b5Syy154373 (l) = 2; \ 60*15d9d0b5Syy154373 else \ 61*15d9d0b5Syy154373 (l) = 1 62*15d9d0b5Syy154373 63*15d9d0b5Syy154373 /* Valid GB2312 byte or not. */ 64*15d9d0b5Syy154373 #define KICONV_SC_IS_GB2312_BYTE(b) ((b) >= 0xA1 && (b) <= 0xFE) 65*15d9d0b5Syy154373 66*15d9d0b5Syy154373 /* UTF-8 value of Unicode Plane 1 start code point (U+10000). */ 67*15d9d0b5Syy154373 #define KICONV_SC_PLANE1_UCS4_START (0x10000) 68*15d9d0b5Syy154373 #define KICONV_SC_PLANE1_UTF8_START (0xF0908080) 69*15d9d0b5Syy154373 70*15d9d0b5Syy154373 /* Start code point of GB18030 which maps to U+10000. */ 71*15d9d0b5Syy154373 #define KICONV_SC_PLANE1_GB18030_START (0x90308130) 72*15d9d0b5Syy154373 73*15d9d0b5Syy154373 #endif /* _KERNEL */ 74*15d9d0b5Syy154373 75*15d9d0b5Syy154373 #ifdef __cplusplus 76*15d9d0b5Syy154373 } 77*15d9d0b5Syy154373 #endif 78*15d9d0b5Syy154373 79*15d9d0b5Syy154373 #endif /* _SYS_KICONV_SC_H */ 80