mbrtoc16(), mbrtoc32()

Updated: October 26, 2022

Convert a multibyte character (UTF-8) into a wide character (UTF-16 or UTF-32)

Synopsis:

#include <uchar.h>

size_t mbrtoc16( char16_t *pwc,
                 const char *s,
 	         size_t n,
                 mbstate_t *ps);

size_t mbrtoc32( char32_t *pwc,
                 const char *s,
 	         size_t n,
                 mbstate_t *ps);

Arguments:

pwc
A pointer to a location where the function can store the wide character.
s
NULL, or an array of characters that make up a multibyte character.
n
The maximum number of bytes to convert from the multibyte character.
ps
A pointer to a conversion object that's used to store state information so that the function can be restarted. You can call mbsinit() to determine the status of this variable.
Note: If the s argument is NULL, the values of pwc and n will be ignored and the call is equivalent to mbrtoc16 (NULL, "", 1, ps) or mbrtoc32 (NULL, "", 1, ps).

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The mbrtoc16() and mbrtoc32() functions determine the number of bytes in the multibyte string s that complete the next multibyte character, if possible. If pwc isn't NULL, the functions actually do the conversion (from UTF-8 to UTF-16 for type char16_t or UTF-32 for type char32_t).

Returns:

The number of bytes needed to complete the next multibyte character, or:

Classification:

C11

Safety:  
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes