The wctomb function determines the number of bytes needed to represent the multi-byte character corresponding to the code whose value is wchar (including any change in shift state). It store the multi-byte character representation in the array pointed to by s (if s is not a null pointer). At most MB_CUR_MAX characters are stored. If the value of wchar is zero, th wctomb function is left in the initial shift state.
The implementation shall behave as if no library function calls th wctomb function.
If s is a null pointer, wctomb returns a non-zero or zero value, if multi-byte character encodings respectively do or do no have state dependent encodings. If s is not a null pointer the wctomb function either returns zero (if s points to the null character), or returns the number of bytes that are contained in the converted multi-byte character (if the next n or fewer bytes for a valid multi-byte character), or returns -1 (if the do not form a valid multi-byte character).
In no case will the value returned be greater than n or the value of the MB_CUR_MAX macro.