Back to index

openldap  2.4.31
ldap_utf8.h
Go to the documentation of this file.
00001 /* $OpenLDAP$ */
00002 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
00003  *
00004  * Copyright 1998-2012 The OpenLDAP Foundation.
00005  * All rights reserved.
00006  *
00007  * Redistribution and use in source and binary forms, with or without
00008  * modification, are permitted only as authorized by the OpenLDAP
00009  * Public License.
00010  *
00011  * A copy of this license is available in file LICENSE in the
00012  * top-level directory of the distribution or, alternatively, at
00013  * <http://www.OpenLDAP.org/license.html>.
00014  */
00015 /* This notice applies to changes, created by or for Novell, Inc.,
00016  * to preexisting works for which notices appear elsewhere in this file.
00017  *
00018  * Copyright (C) 2000 Novell, Inc. All Rights Reserved.
00019  *
00020  * THIS WORK IS SUBJECT TO U.S. AND INTERNATIONAL COPYRIGHT LAWS AND TREATIES.
00021  * USE, MODIFICATION, AND REDISTRIBUTION OF THIS WORK IS SUBJECT TO VERSION
00022  * 2.0.1 OF THE OPENLDAP PUBLIC LICENSE, A COPY OF WHICH IS AVAILABLE AT
00023  * HTTP://WWW.OPENLDAP.ORG/LICENSE.HTML OR IN THE FILE "LICENSE" IN THE
00024  * TOP-LEVEL DIRECTORY OF THE DISTRIBUTION. ANY USE OR EXPLOITATION OF THIS
00025  * WORK OTHER THAN AS AUTHORIZED IN VERSION 2.0.1 OF THE OPENLDAP PUBLIC
00026  * LICENSE, OR OTHER PRIOR WRITTEN CONSENT FROM NOVELL, COULD SUBJECT THE
00027  * PERPETRATOR TO CRIMINAL AND CIVIL LIABILITY.
00028  */
00029 /* Note: A verbatim copy of version 2.0.1 of the OpenLDAP Public License
00030  * can be found in the file "build/LICENSE-2.0.1" in this distribution
00031  * of OpenLDAP Software.
00032  */
00033 
00034 #ifndef _LDAP_UTF8_H
00035 #define _LDAP_UTF8_H
00036 
00037 #include <lber_types.h>     /* get ber_*_t */
00038 
00039 /*
00040  * UTF-8 Utility Routines
00041  */
00042 
00043 LDAP_BEGIN_DECL
00044 
00045 #define LDAP_UCS4_INVALID (0x80000000U)
00046 typedef ber_int_t ldap_ucs4_t;
00047 
00048 
00049 /* LDAP_MAX_UTF8_LEN is 3 or 6 depending on size of wchar_t */
00050 #define LDAP_MAX_UTF8_LEN  ( sizeof(wchar_t) * 3/2 )
00051 
00052 /* Unicode conversion routines  */
00053 LDAP_F( ldap_ucs4_t ) ldap_x_utf8_to_ucs4( LDAP_CONST char * p );
00054 LDAP_F( int ) ldap_x_ucs4_to_utf8( ldap_ucs4_t c, char *buf );
00055 
00056 
00057 /*
00058  * Wide Char / UTF-8 Conversion Routines
00059  */
00060 
00061 /* UTF-8 character to Wide Char */
00062 LDAP_F(int) ldap_x_utf8_to_wc LDAP_P((
00063        wchar_t *wchar, LDAP_CONST char *utf8char ));
00064 
00065 /* UTF-8 string to Wide Char string */
00066 LDAP_F(int) ldap_x_utf8s_to_wcs LDAP_P((
00067        wchar_t *wcstr, LDAP_CONST char *utf8str, size_t count ));
00068 
00069 /* Wide Char to UTF-8 character */
00070 LDAP_F(int) ldap_x_wc_to_utf8 LDAP_P((
00071        char *utf8char, wchar_t wchar, size_t count ));
00072 
00073 /* Wide Char string to UTF-8 string */
00074 LDAP_F(int) ldap_x_wcs_to_utf8s LDAP_P((
00075        char *utf8str, LDAP_CONST wchar_t *wcstr, size_t count ));
00076 
00077 /*
00078  * MultiByte Char / UTF-8 Conversion Routines
00079  */
00080 
00081 /* UTF-8 character to MultiByte character */
00082 LDAP_F(int) ldap_x_utf8_to_mb LDAP_P((
00083        char *mbchar, LDAP_CONST char *utf8char,
00084        int (*ldap_f_wctomb)( char *mbchar, wchar_t wchar )));
00085 
00086 /* UTF-8 string to MultiByte string */
00087 LDAP_F(int) ldap_x_utf8s_to_mbs LDAP_P((
00088        char *mbstr, LDAP_CONST char *utf8str, size_t count,
00089        size_t (*ldap_f_wcstombs)( char *mbstr,
00090               LDAP_CONST wchar_t *wcstr, size_t count) ));
00091 
00092 /* MultiByte character to UTF-8 character */
00093 LDAP_F(int) ldap_x_mb_to_utf8 LDAP_P((
00094        char *utf8char, LDAP_CONST char *mbchar, size_t mbsize,
00095        int (*ldap_f_mbtowc)( wchar_t *wchar,
00096               LDAP_CONST char *mbchar, size_t count) ));
00097 
00098 /* MultiByte string to UTF-8 string */
00099 LDAP_F(int) ldap_x_mbs_to_utf8s LDAP_P((
00100        char *utf8str, LDAP_CONST char *mbstr, size_t count,
00101        size_t (*ldap_f_mbstowcs)( wchar_t *wcstr,
00102               LDAP_CONST char *mbstr, size_t count) ));
00103 
00104 LDAP_END_DECL
00105 
00106 #endif /* _LDAP_UTF8_H */