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);
- A pointer to a buffer where the function can store the multibyte-character string.
- A pointer to the wide-character string that you want to convert.
- The maximum number of multibyte characters to store.
- An internal pointer that lets wcsrtombs() be a restartable
if ps is NULL, wcsrtombs() uses its
own internal variable.
You can call mbsinit() to determine the status of this variable.
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:
- A sequence of bytes doesn't conform to a valid character.
- Converting the next character would exceed the limit of len total bytes.
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.