FAT | RFS | XFS | ZFS

utf8_utf16()

PROTOTYPE

#include <posix.h>

size_t utf8_utf16(const uint8_t *utf8, size_t utf8_len, uint16_t *utf16, size_t max_utf16_len);

DESCRIPTION

*utf8_utf16() converts the UTF8 formatted string utf8, whose length is utf8_len, to the UTF16 format. utf16 points to an output buffer whose size is max_utf16_len.

If successful, utf8_utf16() returns the length of the converted string. Otherwise, it sets errno and returns -1.

ERROR CODES

EFAULT utf8 or utf16 equals NULL.
EINVAL max_utf16_len is zero or an invalid UTF8 char was found.
ENAMETOOLONG The output buffer is too small.

EXAMPLE

  /*-------------------------------------------------------------------*/
  /* Convert UTF8 name to UTF16 encoding.                              */
  /*-------------------------------------------------------------------*/
  i = utf8_utf16((const ui8 *)path, path_len, long_name, LONG_FILENAME);
  if (i == (ui32)-1)
    return -1;