ldap_x_utf8_to_wc

Convert a single UTF-8 encoded character to a wide 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_to_wc (
     wchar_t     *wchar,
     const char  *utf8char);
  

Parameters

wchar

(OUT) Points to a wide character to receive the converted character code.

utf8char

(IN) Address of the UTF8 sequence of bytes.

Return Values

If successful, the function returns the length in bytes of the UTF-8 input character.

If utf8char is NULL or points to an empty string, the function returns 1 and a NULL is written to wchar.

If utf8char contains an invalid UTF-8 sequence -1 is returned.

Example

  char utchr_in[] = { 0xE2U, 0x98U, 0xA0U };
  wchar_t wc_out;
  int n;
  
  /* Convert a UTF-8 character to a wide character.
     Returns wc_out = 0x2620.
     Returns n = 3.  (Byte length of utchr_in)
  */
  n = ldap_x_utf8_to_wc(&wc_out, utchr_in);