std::wctomb (3) - Linux Manuals
std::wctomb: std::wctomb
NAME
Synopsis
Defined in header <cstdlib>
int wctomb( char *s, wchar_t wc );
Converts a wide character wc to multibyte encoding and stores it (including any shift sequences) in the char array whose first element is pointed to by s. No more than MB_CUR_MAX characters are stored.
If wc is the null character, the null byte is written to s, preceded by any shift sequences necessary to restore the initial shift state.
If s is a null pointer, resets the global conversion state and determines whether shift sequences are used.
Parameters
s - pointer to the character array for output
wc - wide character to convert
Return value
If s is not a null pointer, returns the number of bytes that are contained in the multibyte representation of wc or -1 if wc is not a valid character.
If s is a null pointer, resets its internal conversion state to represent the initial shift state and returns 0 if the current multibyte encoding is not state-dependent (does not use shift sequences) or a non-zero value if the current multibyte encoding is state-dependent (uses shift sequences).
Notes
Each call to wctomb updates the internal global conversion state (a static object of type std::mbstate_t, only known to this function). If the multibyte encoding uses shift states, this function is not reentrant. In any case, multiple threads should not call wctomb without synchronization: std::wcrtomb may be used instead.
Example
// Run this code
Output:
See also
mbtowc (function)
wcrtomb (function)
do_out converts a string from internT to externT, such as when writing to file
[virtual]