1*4703203dSis /*
2*4703203dSis  * CDDL HEADER START
3*4703203dSis  *
4*4703203dSis  * The contents of this file are subject to the terms of the
5*4703203dSis  * Common Development and Distribution License (the "License").
6*4703203dSis  * You may not use this file except in compliance with the License.
7*4703203dSis  *
8*4703203dSis  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*4703203dSis  * or http://www.opensolaris.org/os/licensing.
10*4703203dSis  * See the License for the specific language governing permissions
11*4703203dSis  * and limitations under the License.
12*4703203dSis  *
13*4703203dSis  * When distributing Covered Code, include this CDDL HEADER in each
14*4703203dSis  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*4703203dSis  * If applicable, add the following below this CDDL HEADER, with the
16*4703203dSis  * fields enclosed by brackets "[]" replaced with your own identifying
17*4703203dSis  * information: Portions Copyright [yyyy] [name of copyright owner]
18*4703203dSis  *
19*4703203dSis  * CDDL HEADER END
20*4703203dSis  */
21*4703203dSis /*
22*4703203dSis  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23*4703203dSis  * Use is subject to license terms.
24*4703203dSis  */
25*4703203dSis 
26*4703203dSis #ifndef	_SYS_U8_TEXTPREP_H
27*4703203dSis #define	_SYS_U8_TEXTPREP_H
28*4703203dSis 
29*4703203dSis #include <sys/isa_defs.h>
30*4703203dSis #include <sys/types.h>
31*4703203dSis #include <sys/errno.h>
32*4703203dSis 
33*4703203dSis #ifdef	__cplusplus
34*4703203dSis extern "C" {
35*4703203dSis #endif
36*4703203dSis 
37*4703203dSis /*
38*4703203dSis  * Unicode encoding conversion functions and their macros.
39*4703203dSis  */
40*4703203dSis #define	UCONV_IN_BIG_ENDIAN		0x0001
41*4703203dSis #define	UCONV_OUT_BIG_ENDIAN		0x0002
42*4703203dSis #define	UCONV_IN_SYSTEM_ENDIAN		0x0004
43*4703203dSis #define	UCONV_OUT_SYSTEM_ENDIAN		0x0008
44*4703203dSis #define	UCONV_IN_LITTLE_ENDIAN		0x0010
45*4703203dSis #define	UCONV_OUT_LITTLE_ENDIAN		0x0020
46*4703203dSis #define	UCONV_IGNORE_NULL		0x0040
47*4703203dSis #define	UCONV_IN_ACCEPT_BOM		0x0080
48*4703203dSis #define	UCONV_OUT_EMIT_BOM		0x0100
49*4703203dSis 
50*4703203dSis extern int uconv_u16tou32(const uint16_t *, size_t *, uint32_t *, size_t *,
51*4703203dSis 	int);
52*4703203dSis extern int uconv_u16tou8(const uint16_t *, size_t *, uchar_t *, size_t *, int);
53*4703203dSis extern int uconv_u32tou16(const uint32_t *, size_t *, uint16_t *, size_t *,
54*4703203dSis 	int);
55*4703203dSis extern int uconv_u32tou8(const uint32_t *, size_t *, uchar_t *, size_t *, int);
56*4703203dSis extern int uconv_u8tou16(const uchar_t *, size_t *, uint16_t *, size_t *, int);
57*4703203dSis extern int uconv_u8tou32(const uchar_t *, size_t *, uint32_t *, size_t *, int);
58*4703203dSis 
59*4703203dSis /*
60*4703203dSis  * UTF-8 text preparation functions and their macros.
61*4703203dSis  *
62*4703203dSis  * Among the macros defined, U8_CANON_DECOMP, U8_COMPAT_DECOMP, and
63*4703203dSis  * U8_CANON_COMP are not public interfaces and must not be used directly
64*4703203dSis  * at the flag input argument.
65*4703203dSis  */
66*4703203dSis #define	U8_STRCMP_CS			(0x00000001)
67*4703203dSis #define	U8_STRCMP_CI_UPPER		(0x00000002)
68*4703203dSis #define	U8_STRCMP_CI_LOWER		(0x00000004)
69*4703203dSis 
70*4703203dSis #define	U8_CANON_DECOMP			(0x00000010)
71*4703203dSis #define	U8_COMPAT_DECOMP		(0x00000020)
72*4703203dSis #define	U8_CANON_COMP			(0x00000040)
73*4703203dSis 
74*4703203dSis #define	U8_STRCMP_NFD			(U8_CANON_DECOMP)
75*4703203dSis #define	U8_STRCMP_NFC			(U8_CANON_DECOMP | U8_CANON_COMP)
76*4703203dSis #define	U8_STRCMP_NFKD			(U8_COMPAT_DECOMP)
77*4703203dSis #define	U8_STRCMP_NFKC			(U8_COMPAT_DECOMP | U8_CANON_COMP)
78*4703203dSis 
79*4703203dSis #define	U8_TEXTPREP_TOUPPER		(U8_STRCMP_CI_UPPER)
80*4703203dSis #define	U8_TEXTPREP_TOLOWER		(U8_STRCMP_CI_LOWER)
81*4703203dSis 
82*4703203dSis #define	U8_TEXTPREP_NFD			(U8_STRCMP_NFD)
83*4703203dSis #define	U8_TEXTPREP_NFC			(U8_STRCMP_NFC)
84*4703203dSis #define	U8_TEXTPREP_NFKD		(U8_STRCMP_NFKD)
85*4703203dSis #define	U8_TEXTPREP_NFKC		(U8_STRCMP_NFKC)
86*4703203dSis 
87*4703203dSis #define	U8_TEXTPREP_IGNORE_NULL		(0x00010000)
88*4703203dSis #define	U8_TEXTPREP_IGNORE_INVALID	(0x00020000)
89*4703203dSis #define	U8_TEXTPREP_NOWAIT		(0x00040000)
90*4703203dSis 
91*4703203dSis #define	U8_UNICODE_320			(0)
92*4703203dSis #define	U8_UNICODE_500			(1)
93*4703203dSis #define	U8_UNICODE_LATEST		(U8_UNICODE_500)
94*4703203dSis 
95*4703203dSis #define	U8_VALIDATE_ENTIRE		(0x00100000)
96*4703203dSis #define	U8_VALIDATE_CHECK_ADDITIONAL	(0x00200000)
97*4703203dSis #define	U8_VALIDATE_UCS2_RANGE		(0x00400000)
98*4703203dSis 
99*4703203dSis #define	U8_ILLEGAL_CHAR			(-1)
100*4703203dSis #define	U8_OUT_OF_RANGE_CHAR		(-2)
101*4703203dSis 
102*4703203dSis extern int u8_validate(char *, size_t, char **, int, int *);
103*4703203dSis extern int u8_strcmp(const char *, const char *, size_t, int, size_t, int *);
104*4703203dSis extern size_t u8_textprep_str(char *, size_t *, char *, size_t *, int, size_t,
105*4703203dSis 	int *);
106*4703203dSis 
107*4703203dSis #ifdef	__cplusplus
108*4703203dSis }
109*4703203dSis #endif
110*4703203dSis 
111*4703203dSis #endif	/* _SYS_U8_TEXTPREP_H */
112