X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libraries%2Flibldap%2Futf-8-conv.c;h=9b51bcd6f6c041ac52fd0743e3178bef0a1fe534;hb=bb17493d31e19c47bc3a906a39ffa3d57e28aaa4;hp=04a464a7950cfbc6dbf364c15196c7e0790f49fb;hpb=5082731e24ede6bbddb68364f138c3f1f019dfcb;p=openldap diff --git a/libraries/libldap/utf-8-conv.c b/libraries/libldap/utf-8-conv.c index 04a464a795..9b51bcd6f6 100644 --- a/libraries/libldap/utf-8-conv.c +++ b/libraries/libldap/utf-8-conv.c @@ -1,6 +1,6 @@ /* $OpenLDAP$ */ /* - * Copyright 2000 The OpenLDAP Foundation, All Rights Reserved. + * Copyright 2000-2002 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file */ @@ -70,7 +70,7 @@ Note: This code does not prevent UTF-8 sequences which are longer than necessary from being decoded. */ -/*------------------------------------------------------------------------------ +/*----------------------------------------------------------------------------- Convert a UTF-8 character to a wide char. Return the length of the UTF-8 input character in bytes. */ @@ -85,9 +85,9 @@ ldap_x_utf8_to_wc ( wchar_t *wchar, const char *utf8char ) utf8char = ""; /* Get UTF-8 sequence length from 1st byte */ - utflen = UTF8_CHARLEN(utf8char); + utflen = LDAP_UTF8_CHARLEN2(utf8char, utflen); - if( utflen==0 || utflen > LDAP_MAX_UTF8_LEN ) + if( utflen==0 || utflen > (int)LDAP_MAX_UTF8_LEN ) return -1; /* Invalid input */ /* First byte minus length tag */ @@ -130,9 +130,9 @@ ldap_x_utf8s_to_wcs ( wchar_t *wcstr, const char *utf8str, size_t count ) while ( *utf8str && (wcstr==NULL || wclen LDAP_MAX_UTF8_LEN ) + if( utflen==0 || utflen > (int)LDAP_MAX_UTF8_LEN ) return -1; /* Invalid input */ /* First byte minus length tag */ @@ -163,7 +163,7 @@ ldap_x_utf8s_to_wcs ( wchar_t *wcstr, const char *utf8str, size_t count ) } -/*------------------------------------------------------------------------------ +/*----------------------------------------------------------------------------- Convert one wide char to a UTF-8 character. Return the length of the converted UTF-8 character in bytes. No more than 'count' bytes will be written to the output buffer.