ldap_x_utf8_charlen

Return the number of bytes in a UTF-8 character.

Library:*ldapsdk.*
Platform:NLM, Windows (NT, 95, 98, 2000, XP, Vista 32-bit and 64-bit ), Linux (32-bit and 64-bit), Solaris, AIX, and HP-UX

Syntax

  #include <ldap_utf8.h>
  
  int ldap_x_utf8_charlen (
     const char *p);
  

Parameters

p

(IN) Points to the UTF-8 character.

Return Values

Returns length in bytes of the UTF-8 character. (1-6). 0 is returned for an invalid character.

Remarks

The length of the character is determined by looking only at the first byte of the UTF-8 character.

Example

  /* String starts with a 3-byte UTF-8 character. */
  char utstr[] = { 0xe2U, 0x98U, 0xa0U, ’a’, ’b’, ’c’, 0 };
  int n = ldap_x_utf8_charlen(utstr);       /* Returns 3 */
  n = ldap_x_utf8_charlen(utstr+4);   /* ’b’ char.  Returns 1 */