wcsrtombs()

Convert a wide-character string into a multibyte character string (restartable)

Synopsis:

#include <wchar.h>

size_t wcsrtombs( char * dst, 
                  const wchar_t ** src,
                  size_t len, 
                  mbstate_t * ps);

Arguments:

dst
A pointer to a buffer where the function can store the multibyte-character string.
src
A pointer to the wide-character string that you want to convert.
len
The maximum number of multibyte characters to store.
ps
An internal pointer that lets wcsrtombs() be a restartable version of wcstombs(); if ps is NULL, wcsrtombs() uses its own internal variable.

You can call mbsinit() to determine the status of this variable.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

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.

Returns:

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.

Classification:

ANSI, POSIX 1003.1

Safety:
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

wcrtomb(), wcstod(), wcstof(), wcstold(), wcstoimax(), wcstoumax(), wcstok(), wcstol(), wcstoll(), wcstombs(), wcstoul(), wcstoull(), wctob(), wctomb()