libs: Import code from upstream openldap 2.5.13.
[wine.git] / libs / ldap / include / ldap_utf8.h
blob663043a594f820ea2df71b4f2625704d49288b96
1 /* $OpenLDAP$ */
2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 * Copyright 1998-2022 The OpenLDAP Foundation.
5 * All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted only as authorized by the OpenLDAP
9 * Public License.
11 * A copy of this license is available in file LICENSE in the
12 * top-level directory of the distribution or, alternatively, at
13 * <http://www.OpenLDAP.org/license.html>.
15 /* This notice applies to changes, created by or for Novell, Inc.,
16 * to preexisting works for which notices appear elsewhere in this file.
18 * Copyright (C) 2000 Novell, Inc. All Rights Reserved.
20 * THIS WORK IS SUBJECT TO U.S. AND INTERNATIONAL COPYRIGHT LAWS AND TREATIES.
21 * USE, MODIFICATION, AND REDISTRIBUTION OF THIS WORK IS SUBJECT TO VERSION
22 * 2.0.1 OF THE OPENLDAP PUBLIC LICENSE, A COPY OF WHICH IS AVAILABLE AT
23 * HTTP://WWW.OPENLDAP.ORG/LICENSE.HTML OR IN THE FILE "LICENSE" IN THE
24 * TOP-LEVEL DIRECTORY OF THE DISTRIBUTION. ANY USE OR EXPLOITATION OF THIS
25 * WORK OTHER THAN AS AUTHORIZED IN VERSION 2.0.1 OF THE OPENLDAP PUBLIC
26 * LICENSE, OR OTHER PRIOR WRITTEN CONSENT FROM NOVELL, COULD SUBJECT THE
27 * PERPETRATOR TO CRIMINAL AND CIVIL LIABILITY.
29 /* Note: A verbatim copy of version 2.0.1 of the OpenLDAP Public License
30 * can be found in the file "build/LICENSE-2.0.1" in this distribution
31 * of OpenLDAP Software.
34 #ifndef _LDAP_UTF8_H
35 #define _LDAP_UTF8_H
37 #include <lber_types.h> /* get ber_*_t */
40 * UTF-8 Utility Routines
43 LDAP_BEGIN_DECL
45 #define LDAP_UCS4_INVALID (0x80000000U)
46 typedef ber_int_t ldap_ucs4_t;
49 /* LDAP_MAX_UTF8_LEN is 3 or 6 depending on size of wchar_t */
50 #define LDAP_MAX_UTF8_LEN ( sizeof(wchar_t) * 3/2 )
52 /* Unicode conversion routines */
53 LDAP_F( ldap_ucs4_t ) ldap_x_utf8_to_ucs4( LDAP_CONST char * p );
54 LDAP_F( int ) ldap_x_ucs4_to_utf8( ldap_ucs4_t c, char *buf );
58 * Wide Char / UTF-8 Conversion Routines
61 /* UTF-8 character to Wide Char */
62 LDAP_F(int) ldap_x_utf8_to_wc LDAP_P((
63 wchar_t *wchar, LDAP_CONST char *utf8char ));
65 /* UTF-8 string to Wide Char string */
66 LDAP_F(int) ldap_x_utf8s_to_wcs LDAP_P((
67 wchar_t *wcstr, LDAP_CONST char *utf8str, size_t count ));
69 /* Wide Char to UTF-8 character */
70 LDAP_F(int) ldap_x_wc_to_utf8 LDAP_P((
71 char *utf8char, wchar_t wchar, size_t count ));
73 /* Wide Char string to UTF-8 string */
74 LDAP_F(int) ldap_x_wcs_to_utf8s LDAP_P((
75 char *utf8str, LDAP_CONST wchar_t *wcstr, size_t count ));
78 * MultiByte Char / UTF-8 Conversion Routines
81 /* UTF-8 character to MultiByte character */
82 LDAP_F(int) ldap_x_utf8_to_mb LDAP_P((
83 char *mbchar, LDAP_CONST char *utf8char,
84 int (*ldap_f_wctomb)( char *mbchar, wchar_t wchar )));
86 /* UTF-8 string to MultiByte string */
87 LDAP_F(int) ldap_x_utf8s_to_mbs LDAP_P((
88 char *mbstr, LDAP_CONST char *utf8str, size_t count,
89 size_t (*ldap_f_wcstombs)( char *mbstr,
90 LDAP_CONST wchar_t *wcstr, size_t count) ));
92 /* MultiByte character to UTF-8 character */
93 LDAP_F(int) ldap_x_mb_to_utf8 LDAP_P((
94 char *utf8char, LDAP_CONST char *mbchar, size_t mbsize,
95 int (*ldap_f_mbtowc)( wchar_t *wchar,
96 LDAP_CONST char *mbchar, size_t count) ));
98 /* MultiByte string to UTF-8 string */
99 LDAP_F(int) ldap_x_mbs_to_utf8s LDAP_P((
100 char *utf8str, LDAP_CONST char *mbstr, size_t count,
101 size_t (*ldap_f_mbstowcs)( wchar_t *wcstr,
102 LDAP_CONST char *mbstr, size_t count) ));
104 LDAP_END_DECL
106 #endif /* _LDAP_UTF8_H */