Go to main content

man pages section 3: Basic Library Functions

Exit Print View

Updated: Wednesday, July 27, 2022
 
 

c32rtomb (3C)

Name

c32rtomb - restartable multibyte/wide character conversion function

Synopsis

#include <uchar.h>
size_t c32rtomb(char * restrict s, char32_t c32, mbstate_t * restrict ps);

Description

If s is a null pointer, the c32rtomb() function is equivalent to the call

c32rtomb(buf, L'\0', ps)

where buf is an internal buffer.

If s is not a null pointer, the c32rtomb() function determines the number of bytes needed to represent the multibyte character that corresponds to the wide character given by c32 (including any shift sequences), and stores the multibyte character representation in the array whose first element is pointed to by s. At most MB_CUR_MAX bytes are stored. If c32 is a null wide character, a null byte is stored, preceded by any shift sequence needed to restore the initial shift state; the resulting state described is the initial conversion state.

Return Values

The c32rtomb() function returns the number of bytes stored in the array object (including any shift sequences). When c32 is not a valid wide character, an encoding error occurs: the function stores the value of the macro EILSEQ in errno and returns (size_t)(-1); the conversion state is unspecified.

Errors

The c32rtomb() function will fail if:

EINVAL

The ps argument points to an object that contains an invalid conversion state.

EILSEQ

Invalid character sequence is detected.

The c32rtomb() function may fail if:

ENOMEM

Insufficient storage space is available.

Attributes

See attributes(7) for descriptions of the following attributes:

ATTRIBUTE TYPE
ATTRIBUTE VALUE
Interface Stability
Committed
MT-Level
See NOTES below
Standard

See Also

mbsinit(3C), setlocale(3C), attributes(7), standards(7)

Notes

If ps is not a null pointer, the function uses the mbstate_t object pointed to by ps and the function can be used safely in multithreaded applications. If ps is a null pointer, the function uses its internal mbstate_t object and the function is Unsafe in multithreaded applications.