Convert a wide-character string into a multibyte character string (restartable)
#include <wchar.h> size_t wcsrtombs( char * dst, const wchar_t ** src, size_t len, mbstate_t * ps);
You can call mbsinit() to determine the status of this variable.
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The wcsrtombs() function converts a string of wide-characters pointed to by src into the corresponding multi-byte characters pointed to by dst. No more than len bytes are stored, including the terminating NULL character.
The function converts each character as if by a call to wctomb() and stops early if:
The wcsrtombs() function uses ps to make it thread safe; if ps is a NULL pointer, wcsrtombs() uses its own internal pointer.
The number of total bytes successfully converted, not including the terminating NULL byte, or (size_t)-1 if an invalid wide-character code was found.
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | Yes |
Thread | Read the Caveats |
This function is safe to call in a multithreaded program if the ps argument isn't NULL.