+/* utf-8.c -- Basic UTF-8 routines */
/* $OpenLDAP$ */
-/*
- * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
+ *
+ * Copyright 1998-2012 The OpenLDAP Foundation.
+ * All rights reserved.
+ *
+ * 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 in the file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * <http://www.OpenLDAP.org/license.html>.
*/
-
-/*
- * Basic UTF-8 routines
+/* Basic UTF-8 routines
*
* These routines are "dumb". Though they understand UTF-8,
* they don't grok Unicode. That is, they can push bits,
#include "ldap-int.h"
#include "ldap_defaults.h"
-/*
- * Basic UTF-8 routines
- */
-
/*
* return the number of bytes required to hold the
* NULL-terminated UTF-8 string NOT INCLUDING the
/* conv UTF-8 to UCS-4, useful for comparisons */
ldap_ucs4_t ldap_x_utf8_to_ucs4( const char * p )
{
- const unsigned char *c = p;
+ const unsigned char *c = (const unsigned char *) p;
ldap_ucs4_t ch;
int len, i;
static unsigned char mask[] = {
int ldap_x_ucs4_to_utf8( ldap_ucs4_t c, char *buf )
{
int len=0;
- unsigned char* p = buf;
+ unsigned char* p = (unsigned char *) buf;
/* not a valid Unicode character */
if ( c < 0 ) return 0;
char* ldap_utf8_next( const char * p )
{
int i;
- const unsigned char *u = p;
+ const unsigned char *u = (const unsigned char *) p;
if( LDAP_UTF8_ISASCII(u) ) {
return (char *) &p[1];
char* ldap_utf8_prev( const char * p )
{
int i;
- const unsigned char *u = p;
+ const unsigned char *u = (const unsigned char *) p;
for( i=-1; i>-6 ; i-- ) {
if ( ( u[i] & 0xc0 ) != 0x80 ) {
int ldap_utf8_copy( char* dst, const char *src )
{
int i;
- const unsigned char *u = src;
+ const unsigned char *u = (const unsigned char *) src;
dst[0] = src[0];