/* $OpenLDAP$ */1/* This work is part of OpenLDAP Software <http://www.openldap.org/>.2*3* Copyright 1998-2024 The OpenLDAP Foundation.4* All rights reserved.5*6* Redistribution and use in source and binary forms, with or without7* modification, are permitted only as authorized by the OpenLDAP8* Public License.9*10* A copy of this license is available in file LICENSE in the11* top-level directory of the distribution or, alternatively, at12* <http://www.OpenLDAP.org/license.html>.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 VERSION21* 2.0.1 OF THE OPENLDAP PUBLIC LICENSE, A COPY OF WHICH IS AVAILABLE AT22* HTTP://WWW.OPENLDAP.ORG/LICENSE.HTML OR IN THE FILE "LICENSE" IN THE23* TOP-LEVEL DIRECTORY OF THE DISTRIBUTION. ANY USE OR EXPLOITATION OF THIS24* WORK OTHER THAN AS AUTHORIZED IN VERSION 2.0.1 OF THE OPENLDAP PUBLIC25* LICENSE, OR OTHER PRIOR WRITTEN CONSENT FROM NOVELL, COULD SUBJECT THE26* PERPETRATOR TO CRIMINAL AND CIVIL LIABILITY.27*/28/* Note: A verbatim copy of version 2.0.1 of the OpenLDAP Public License29* can be found in the file "build/LICENSE-2.0.1" in this distribution30* of OpenLDAP Software.31*/3233#ifndef _LDAP_UTF8_H34#define _LDAP_UTF8_H3536#include <lber_types.h> /* get ber_*_t */3738/*39* UTF-8 Utility Routines40*/4142LDAP_BEGIN_DECL4344#define LDAP_UCS4_INVALID (0x80000000U)45typedef ber_int_t ldap_ucs4_t;464748/* LDAP_MAX_UTF8_LEN is 3 or 6 depending on size of wchar_t */49#define LDAP_MAX_UTF8_LEN ( sizeof(wchar_t) * 3/2 )5051/* Unicode conversion routines */52LDAP_F( ldap_ucs4_t ) ldap_x_utf8_to_ucs4( LDAP_CONST char * p );53LDAP_F( int ) ldap_x_ucs4_to_utf8( ldap_ucs4_t c, char *buf );545556/*57* Wide Char / UTF-8 Conversion Routines58*/5960/* UTF-8 character to Wide Char */61LDAP_F(int) ldap_x_utf8_to_wc LDAP_P((62wchar_t *wchar, LDAP_CONST char *utf8char ));6364/* UTF-8 string to Wide Char string */65LDAP_F(int) ldap_x_utf8s_to_wcs LDAP_P((66wchar_t *wcstr, LDAP_CONST char *utf8str, size_t count ));6768/* Wide Char to UTF-8 character */69LDAP_F(int) ldap_x_wc_to_utf8 LDAP_P((70char *utf8char, wchar_t wchar, size_t count ));7172/* Wide Char string to UTF-8 string */73LDAP_F(int) ldap_x_wcs_to_utf8s LDAP_P((74char *utf8str, LDAP_CONST wchar_t *wcstr, size_t count ));7576/*77* MultiByte Char / UTF-8 Conversion Routines78*/7980/* UTF-8 character to MultiByte character */81LDAP_F(int) ldap_x_utf8_to_mb LDAP_P((82char *mbchar, LDAP_CONST char *utf8char,83int (*ldap_f_wctomb)( char *mbchar, wchar_t wchar )));8485/* UTF-8 string to MultiByte string */86LDAP_F(int) ldap_x_utf8s_to_mbs LDAP_P((87char *mbstr, LDAP_CONST char *utf8str, size_t count,88size_t (*ldap_f_wcstombs)( char *mbstr,89LDAP_CONST wchar_t *wcstr, size_t count) ));9091/* MultiByte character to UTF-8 character */92LDAP_F(int) ldap_x_mb_to_utf8 LDAP_P((93char *utf8char, LDAP_CONST char *mbchar, size_t mbsize,94int (*ldap_f_mbtowc)( wchar_t *wchar,95LDAP_CONST char *mbchar, size_t count) ));9697/* MultiByte string to UTF-8 string */98LDAP_F(int) ldap_x_mbs_to_utf8s LDAP_P((99char *utf8str, LDAP_CONST char *mbstr, size_t count,100size_t (*ldap_f_mbstowcs)( wchar_t *wcstr,101LDAP_CONST char *mbstr, size_t count) ));102103LDAP_END_DECL104105#endif /* _LDAP_UTF8_H */106107108