2000-12-28 10:20:37 +08:00
|
|
|
/* $OpenLDAP$ */
|
|
|
|
/*
|
2003-01-04 04:20:47 +08:00
|
|
|
* Copyright 1998-2003 The OpenLDAP Foundation, Redwood City, California, USA
|
2000-12-28 10:20:37 +08:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
2001-05-29 11:29:53 +08:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted only as authorized by the OpenLDAP
|
|
|
|
* Public License. A copy of this license is available at
|
|
|
|
* http://www.OpenLDAP.org/license.html or in file LICENSE in the
|
|
|
|
* top-level directory of the distribution.
|
2000-12-28 10:20:37 +08:00
|
|
|
*/
|
2001-12-18 06:38:15 +08:00
|
|
|
/* $Novell: /ldap/src/cldap/include/ldap_utf8.h,v 1.3 2000/12/04 20:23:20 dsteck Exp $ */
|
2000-12-28 10:20:37 +08:00
|
|
|
/******************************************************************************
|
|
|
|
* This notice applies to changes, created by or for Novell, Inc.,
|
|
|
|
* to preexisting works for which notices appear elsewhere in this file.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2000 Novell, Inc. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* THIS WORK IS SUBJECT TO U.S. AND INTERNATIONAL COPYRIGHT LAWS AND TREATIES.
|
|
|
|
* USE, MODIFICATION, AND REDISTRIBUTION OF THIS WORK IS SUBJECT TO VERSION
|
|
|
|
* 2.0.1 OF THE OPENLDAP PUBLIC LICENSE, A COPY OF WHICH IS AVAILABLE AT
|
|
|
|
* HTTP://WWW.OPENLDAP.ORG/LICENSE.HTML OR IN THE FILE "LICENSE" IN THE
|
|
|
|
* TOP-LEVEL DIRECTORY OF THE DISTRIBUTION. ANY USE OR EXPLOITATION OF THIS
|
|
|
|
* WORK OTHER THAN AS AUTHORIZED IN VERSION 2.0.1 OF THE OPENLDAP PUBLIC
|
|
|
|
* LICENSE, OR OTHER PRIOR WRITTEN CONSENT FROM NOVELL, COULD SUBJECT THE
|
2001-12-24 11:49:54 +08:00
|
|
|
* PERPETRATOR TO CRIMINAL AND CIVIL LIABILITY.
|
2000-12-28 10:20:37 +08:00
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
#ifndef _LDAP_UTF8_H
|
|
|
|
#define _LDAP_UTF8_H
|
|
|
|
|
2001-07-22 07:13:04 +08:00
|
|
|
#include <lber_types.h> /* get ber_*_t */
|
2000-12-28 10:20:37 +08:00
|
|
|
|
2001-12-24 11:49:54 +08:00
|
|
|
/*
|
2001-05-21 13:00:35 +08:00
|
|
|
* UTF-8 Utility Routines
|
2000-12-28 10:20:37 +08:00
|
|
|
*/
|
|
|
|
|
2001-07-22 07:13:04 +08:00
|
|
|
LDAP_BEGIN_DECL
|
|
|
|
|
2000-12-28 10:20:37 +08:00
|
|
|
#define LDAP_UCS4_INVALID (0x80000000U)
|
2001-07-22 07:13:04 +08:00
|
|
|
typedef ber_int_t ldap_ucs4_t;
|
|
|
|
|
2000-12-28 10:20:37 +08:00
|
|
|
|
|
|
|
/* LDAP_MAX_UTF8_LEN is 3 or 6 depending on size of wchar_t */
|
2001-05-21 13:00:35 +08:00
|
|
|
#define LDAP_MAX_UTF8_LEN ( sizeof(wchar_t) * 3/2 )
|
2000-12-28 10:20:37 +08:00
|
|
|
|
2001-07-22 07:13:04 +08:00
|
|
|
/* Unicode conversion routines */
|
|
|
|
LDAP_F( ldap_ucs4_t ) ldap_x_utf8_to_ucs4( LDAP_CONST char * p );
|
|
|
|
LDAP_F( int ) ldap_x_ucs4_to_utf8( ldap_ucs4_t c, char *buf );
|
|
|
|
|
|
|
|
|
2000-12-28 10:20:37 +08:00
|
|
|
/*
|
2001-05-21 13:00:35 +08:00
|
|
|
* Wide Char / UTF-8 Conversion Routines
|
2000-12-28 10:20:37 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* UTF-8 character to Wide Char */
|
2001-07-23 12:31:41 +08:00
|
|
|
LDAP_F(int) ldap_x_utf8_to_wc LDAP_P((
|
|
|
|
wchar_t *wchar, LDAP_CONST char *utf8char ));
|
2000-12-28 10:20:37 +08:00
|
|
|
|
|
|
|
/* UTF-8 string to Wide Char string */
|
2001-07-23 12:31:41 +08:00
|
|
|
LDAP_F(int) ldap_x_utf8s_to_wcs LDAP_P((
|
|
|
|
wchar_t *wcstr, LDAP_CONST char *utf8str, size_t count ));
|
2000-12-28 10:20:37 +08:00
|
|
|
|
|
|
|
/* Wide Char to UTF-8 character */
|
2001-07-23 12:31:41 +08:00
|
|
|
LDAP_F(int) ldap_x_wc_to_utf8 LDAP_P((
|
|
|
|
char *utf8char, wchar_t wchar, size_t count ));
|
2000-12-28 10:20:37 +08:00
|
|
|
|
|
|
|
/* Wide Char string to UTF-8 string */
|
2001-07-23 12:31:41 +08:00
|
|
|
LDAP_F(int) ldap_x_wcs_to_utf8s LDAP_P((
|
|
|
|
char *utf8str, LDAP_CONST wchar_t *wcstr, size_t count ));
|
2000-12-28 10:20:37 +08:00
|
|
|
|
2001-05-21 13:00:35 +08:00
|
|
|
/*
|
|
|
|
* MultiByte Char / UTF-8 Conversion Routines
|
|
|
|
*/
|
2000-12-28 10:20:37 +08:00
|
|
|
|
|
|
|
/* UTF-8 character to MultiByte character */
|
2001-07-23 12:31:41 +08:00
|
|
|
LDAP_F(int) ldap_x_utf8_to_mb LDAP_P((
|
|
|
|
char *mbchar, LDAP_CONST char *utf8char,
|
|
|
|
int (*ldap_f_wctomb)( char *mbchar, wchar_t wchar )));
|
2000-12-28 10:20:37 +08:00
|
|
|
|
|
|
|
/* UTF-8 string to MultiByte string */
|
2001-07-23 12:31:41 +08:00
|
|
|
LDAP_F(int) ldap_x_utf8s_to_mbs LDAP_P((
|
|
|
|
char *mbstr, LDAP_CONST char *utf8str, size_t count,
|
|
|
|
size_t (*ldap_f_wcstombs)( char *mbstr,
|
|
|
|
LDAP_CONST wchar_t *wcstr, size_t count) ));
|
2000-12-28 10:20:37 +08:00
|
|
|
|
|
|
|
/* MultiByte character to UTF-8 character */
|
2001-07-23 12:31:41 +08:00
|
|
|
LDAP_F(int) ldap_x_mb_to_utf8 LDAP_P((
|
|
|
|
char *utf8char, LDAP_CONST char *mbchar, size_t mbsize,
|
|
|
|
int (*ldap_f_mbtowc)( wchar_t *wchar,
|
|
|
|
LDAP_CONST char *mbchar, size_t count) ));
|
2000-12-28 10:20:37 +08:00
|
|
|
|
|
|
|
/* MultiByte string to UTF-8 string */
|
2001-07-23 12:31:41 +08:00
|
|
|
LDAP_F(int) ldap_x_mbs_to_utf8s LDAP_P((
|
|
|
|
char *utf8str, LDAP_CONST char *mbstr, size_t count,
|
|
|
|
size_t (*ldap_f_mbstowcs)( wchar_t *wcstr,
|
|
|
|
LDAP_CONST char *mbstr, size_t count) ));
|
2000-12-28 10:20:37 +08:00
|
|
|
|
|
|
|
LDAP_END_DECL
|
|
|
|
|
|
|
|
#endif /* _LDAP_UTF8_H */
|