wcrtomb()

convert wide character to multibyte character (restartable) 

Function


SYNOPSIS

#include <wchar.h>

size_t wcrtomb(char *s, wchar_t wc, mbstate_t *ps);


DESCRIPTION

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

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

where buf is an internal buffer.

If s is not a null pointer, the wcrtomb() function determines the number of bytes needed to represent the character that corresponds to the wide character given by wc (including any shift sequences), and stores the resulting bytes in the array pointed to by s. At most MB_CUR_MAX bytes are stored. If wc 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.

If the specified state pointer is null, the wcrtomb() function uses its own internal mbstate_t object, which is initialized at program startup to the initial conversion state. Otherwise, the specified mbstate_t object is used to completely describe the current conversion state of the associated character sequence.

The behavior of this function is affected by the LC_CTYPE category of the current locale.


PARAMETERS

s 

Is the buffer used to receive the converted character. This can be a null pointer if no conversion is desired.

wc 

Is the wide character to convert.

ps 

Is the conversion state. If this is null, an internal mbstate_t object is used.


RETURN VALUES

The wcrtomb() function returns the number of bytes stored in the array object (including any shift sequences). When wc is not a valid wide character, an encoding error occurs. In this case, errno is set to EILSEQ and -1 is returned; the conversion state is undefined.


CONFORMANCE

ANSI/ISO 9899-1990/AM 1-1995


MULTITHREAD SAFETY LEVEL

MT-Safe, with exceptions.

This function is MT-Safe as long as no thread calls setlocale() while this function is executing and the 'ps' parameter is non-NULL.


PORTING ISSUES

None.


AVAILABILITY

MKS Toolkit for Professional Developers
MKS Toolkit for Enterprise Developers
MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
mbrlen(), mbrtowc(), mbsinit(), mbsrtowcs(), setlocale(), wcsrtombs()


MKS Toolkit 9.3 Documentation Build 6.