]> git.sur5r.net Git - openldap/blob - include/ldap_utf8.h
Silence warning in prev commit
[openldap] / include / ldap_utf8.h
1 /* $OpenLDAP$ */
2 /*
3  * Copyright 1998-2003 The OpenLDAP Foundation, Redwood City, California, USA
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted only as authorized by the OpenLDAP
8  * Public License.  A copy of this license is available at
9  * http://www.OpenLDAP.org/license.html or in file LICENSE in the
10  * top-level directory of the distribution.
11  */
12 /* $Novell: /ldap/src/cldap/include/ldap_utf8.h,v 1.3 2000/12/04 20:23:20 dsteck Exp $ */
13 /******************************************************************************
14  * This notice applies to changes, created by or for Novell, Inc.,
15  * to preexisting works for which notices appear elsewhere in this file.
16  *
17  * Copyright (C) 2000 Novell, Inc. All Rights Reserved.
18  *
19  * THIS WORK IS SUBJECT TO U.S. AND INTERNATIONAL COPYRIGHT LAWS AND TREATIES.
20  * USE, MODIFICATION, AND REDISTRIBUTION OF THIS WORK IS SUBJECT TO VERSION
21  * 2.0.1 OF THE OPENLDAP PUBLIC LICENSE, A COPY OF WHICH IS AVAILABLE AT
22  * HTTP://WWW.OPENLDAP.ORG/LICENSE.HTML OR IN THE FILE "LICENSE" IN THE
23  * TOP-LEVEL DIRECTORY OF THE DISTRIBUTION. ANY USE OR EXPLOITATION OF THIS
24  * WORK OTHER THAN AS AUTHORIZED IN VERSION 2.0.1 OF THE OPENLDAP PUBLIC
25  * LICENSE, OR OTHER PRIOR WRITTEN CONSENT FROM NOVELL, COULD SUBJECT THE
26  * PERPETRATOR TO CRIMINAL AND CIVIL LIABILITY.
27  ******************************************************************************/
28
29 #ifndef _LDAP_UTF8_H
30 #define _LDAP_UTF8_H
31
32 #include <lber_types.h> /* get ber_*_t */
33
34 /*
35  * UTF-8 Utility Routines
36  */
37
38 LDAP_BEGIN_DECL
39
40 #define LDAP_UCS4_INVALID (0x80000000U)
41 typedef ber_int_t ldap_ucs4_t;
42
43
44 /* LDAP_MAX_UTF8_LEN is 3 or 6 depending on size of wchar_t */
45 #define LDAP_MAX_UTF8_LEN  ( sizeof(wchar_t) * 3/2 )
46
47 /* Unicode conversion routines  */
48 LDAP_F( ldap_ucs4_t ) ldap_x_utf8_to_ucs4( LDAP_CONST char * p );
49 LDAP_F( int ) ldap_x_ucs4_to_utf8( ldap_ucs4_t c, char *buf );
50
51
52 /*
53  * Wide Char / UTF-8 Conversion Routines
54  */
55
56 /* UTF-8 character to Wide Char */
57 LDAP_F(int) ldap_x_utf8_to_wc LDAP_P((
58         wchar_t *wchar, LDAP_CONST char *utf8char ));
59
60 /* UTF-8 string to Wide Char string */
61 LDAP_F(int) ldap_x_utf8s_to_wcs LDAP_P((
62         wchar_t *wcstr, LDAP_CONST char *utf8str, size_t count ));
63
64 /* Wide Char to UTF-8 character */
65 LDAP_F(int) ldap_x_wc_to_utf8 LDAP_P((
66         char *utf8char, wchar_t wchar, size_t count ));
67
68 /* Wide Char string to UTF-8 string */
69 LDAP_F(int) ldap_x_wcs_to_utf8s LDAP_P((
70         char *utf8str, LDAP_CONST wchar_t *wcstr, size_t count ));
71
72 /*
73  * MultiByte Char / UTF-8 Conversion Routines
74  */
75
76 /* UTF-8 character to MultiByte character */
77 LDAP_F(int) ldap_x_utf8_to_mb LDAP_P((
78         char *mbchar, LDAP_CONST char *utf8char,
79         int (*ldap_f_wctomb)( char *mbchar, wchar_t wchar )));
80
81 /* UTF-8 string to MultiByte string */
82 LDAP_F(int) ldap_x_utf8s_to_mbs LDAP_P((
83         char *mbstr, LDAP_CONST char *utf8str, size_t count,
84         size_t (*ldap_f_wcstombs)( char *mbstr,
85                 LDAP_CONST wchar_t *wcstr, size_t count) ));
86
87 /* MultiByte character to UTF-8 character */
88 LDAP_F(int) ldap_x_mb_to_utf8 LDAP_P((
89         char *utf8char, LDAP_CONST char *mbchar, size_t mbsize,
90         int (*ldap_f_mbtowc)( wchar_t *wchar,
91                 LDAP_CONST char *mbchar, size_t count) ));
92
93 /* MultiByte string to UTF-8 string */
94 LDAP_F(int) ldap_x_mbs_to_utf8s LDAP_P((
95         char *utf8str, LDAP_CONST char *mbstr, size_t count,
96         size_t (*ldap_f_mbstowcs)( wchar_t *wcstr,
97                 LDAP_CONST char *mbstr, size_t count) ));
98
99 LDAP_END_DECL
100
101 #endif /* _LDAP_UTF8_H */