Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-17 09:55:46

0001 /* $OpenLDAP$ */
0002 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
0003  *
0004  * Copyright 1998-2024 The OpenLDAP Foundation.
0005  * All rights reserved.
0006  *
0007  * Redistribution and use in source and binary forms, with or without
0008  * modification, are permitted only as authorized by the OpenLDAP
0009  * Public License.
0010  *
0011  * A copy of this license is available in file LICENSE in the
0012  * top-level directory of the distribution or, alternatively, at
0013  * <http://www.OpenLDAP.org/license.html>.
0014  */
0015 /* This notice applies to changes, created by or for Novell, Inc.,
0016  * to preexisting works for which notices appear elsewhere in this file.
0017  *
0018  * Copyright (C) 2000 Novell, Inc. All Rights Reserved.
0019  *
0020  * THIS WORK IS SUBJECT TO U.S. AND INTERNATIONAL COPYRIGHT LAWS AND TREATIES.
0021  * USE, MODIFICATION, AND REDISTRIBUTION OF THIS WORK IS SUBJECT TO VERSION
0022  * 2.0.1 OF THE OPENLDAP PUBLIC LICENSE, A COPY OF WHICH IS AVAILABLE AT
0023  * HTTP://WWW.OPENLDAP.ORG/LICENSE.HTML OR IN THE FILE "LICENSE" IN THE
0024  * TOP-LEVEL DIRECTORY OF THE DISTRIBUTION. ANY USE OR EXPLOITATION OF THIS
0025  * WORK OTHER THAN AS AUTHORIZED IN VERSION 2.0.1 OF THE OPENLDAP PUBLIC
0026  * LICENSE, OR OTHER PRIOR WRITTEN CONSENT FROM NOVELL, COULD SUBJECT THE
0027  * PERPETRATOR TO CRIMINAL AND CIVIL LIABILITY.
0028  */
0029 /* Note: A verbatim copy of version 2.0.1 of the OpenLDAP Public License
0030  * can be found in the file "build/LICENSE-2.0.1" in this distribution
0031  * of OpenLDAP Software.
0032  */
0033 
0034 #ifndef _LDAP_UTF8_H
0035 #define _LDAP_UTF8_H
0036 
0037 #include <lber_types.h> /* get ber_*_t */
0038 
0039 /*
0040  * UTF-8 Utility Routines
0041  */
0042 
0043 LDAP_BEGIN_DECL
0044 
0045 #define LDAP_UCS4_INVALID (0x80000000U)
0046 typedef ber_int_t ldap_ucs4_t;
0047 
0048 
0049 /* LDAP_MAX_UTF8_LEN is 3 or 6 depending on size of wchar_t */
0050 #define LDAP_MAX_UTF8_LEN  ( sizeof(wchar_t) * 3/2 )
0051 
0052 /* Unicode conversion routines  */
0053 LDAP_F( ldap_ucs4_t ) ldap_x_utf8_to_ucs4( LDAP_CONST char * p );
0054 LDAP_F( int ) ldap_x_ucs4_to_utf8( ldap_ucs4_t c, char *buf );
0055 
0056 
0057 /*
0058  * Wide Char / UTF-8 Conversion Routines
0059  */
0060 
0061 /* UTF-8 character to Wide Char */
0062 LDAP_F(int) ldap_x_utf8_to_wc LDAP_P((
0063     wchar_t *wchar, LDAP_CONST char *utf8char ));
0064 
0065 /* UTF-8 string to Wide Char string */
0066 LDAP_F(int) ldap_x_utf8s_to_wcs LDAP_P((
0067     wchar_t *wcstr, LDAP_CONST char *utf8str, size_t count ));
0068 
0069 /* Wide Char to UTF-8 character */
0070 LDAP_F(int) ldap_x_wc_to_utf8 LDAP_P((
0071     char *utf8char, wchar_t wchar, size_t count ));
0072 
0073 /* Wide Char string to UTF-8 string */
0074 LDAP_F(int) ldap_x_wcs_to_utf8s LDAP_P((
0075     char *utf8str, LDAP_CONST wchar_t *wcstr, size_t count ));
0076 
0077 /*
0078  * MultiByte Char / UTF-8 Conversion Routines
0079  */
0080 
0081 /* UTF-8 character to MultiByte character */
0082 LDAP_F(int) ldap_x_utf8_to_mb LDAP_P((
0083     char *mbchar, LDAP_CONST char *utf8char,
0084     int (*ldap_f_wctomb)( char *mbchar, wchar_t wchar )));
0085 
0086 /* UTF-8 string to MultiByte string */
0087 LDAP_F(int) ldap_x_utf8s_to_mbs LDAP_P((
0088     char *mbstr, LDAP_CONST char *utf8str, size_t count,
0089     size_t (*ldap_f_wcstombs)( char *mbstr,
0090         LDAP_CONST wchar_t *wcstr, size_t count) ));
0091 
0092 /* MultiByte character to UTF-8 character */
0093 LDAP_F(int) ldap_x_mb_to_utf8 LDAP_P((
0094     char *utf8char, LDAP_CONST char *mbchar, size_t mbsize,
0095     int (*ldap_f_mbtowc)( wchar_t *wchar,
0096         LDAP_CONST char *mbchar, size_t count) ));
0097 
0098 /* MultiByte string to UTF-8 string */
0099 LDAP_F(int) ldap_x_mbs_to_utf8s LDAP_P((
0100     char *utf8str, LDAP_CONST char *mbstr, size_t count,
0101     size_t (*ldap_f_mbstowcs)( wchar_t *wcstr,
0102         LDAP_CONST char *mbstr, size_t count) ));
0103 
0104 LDAP_END_DECL
0105 
0106 #endif /* _LDAP_UTF8_H */