-> Click here to learn how to get live help <-
NAMEwcrtomb - convert a wide character to a multibyte sequence
#include <wchar.h> size_t wcrtomb(char *s, wchar_t wc, mbstate_t *ps);
DESCRIPTIONThe main case for this function is when fIsfP is not NULL and fIwcfP is not L' '. In this case, the fBwcrtombfP function converts the wide character fIwcfP to its multibyte representation and stores it at the beginning of the character array pointed to by fIsfP. It updates the shift state fI*psfP, and returns the length of said multibyte representation, i.e. the number of bytes written at fIsfP.
A different case is when fIsfP is not NULL but fIwcfP is L' '. In this case the fBwcrtombfP function stores at the character array pointed to by fIsfP the shift sequence needed to bring fI*psfP back to the initial state, followed by a ' ' byte. It updates the shift state fI*psfP (i.e. brings it into the initial state), and returns the length of the shift sequence plus one, i.e. the number of bytes written at fIsfP.
A third case is when fIsfP is NULL. In this case fIwcfP is ignored, and the function effectively returns wcrtomb(buf,L' ',fIpsfP) where buf is an internal anonymous buffer.
RETURN VALUEThe fBwcrtombfP function returns the number of bytes that have been or would have been written to the byte array at fIsfP. If fIwcfP can not be represented as a multibyte sequence (according to the current locale), (size_t)(-1) is returned, and fBerrnofP set to fBEILSEQfP.
CONFORMING TOISO/ANSI C, UNIX98
NOTESThe behaviour of fBwcrtombfP depends on the LC_CTYPE category of the current locale.
Passing NULL as fIpsfP is not multi-thread safe.