Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

wcsrtombs - Convert wide character string to multibyte character string

&pagelevel(4)&pagelevel

Definition   

#include <wchar.h>

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

wcrtombs converts a sequence of wide characters, beginning in the conversion state described by the object pointed to by *ps, from the array indirectly pointed to by src into a sequence of corresponding multibyte characters. If dst is not a null pointer, the converted characters are stored into the array pointed to by dst. Each conversion takes place as if by a call to the wcrtomb function.

Conversion stops on encountering a terminating null character, which is also converted and stored in the array.

Conversion stops earlier in two cases:

  • when a sequence of bytes that does not correspond o a valid multibyte character is encountered or

  • if dst is not a null pointer, when the next multibyte character would exceed the maximum length len of the bytes to be stored in the array

If dst is not a null pointer, the pointer object pointed to by src is assigned one of the following values:

  • a null pointer if conversion stopped due to reaching a terminating null character

  • the address just past the last converted wide character (if any).

If dst is not a null pointer and if the conversion stopped due to reaching a terminating null character, the resulting state described is the initial conversion state.

Return val.

(size_t)-1

if a conversion error occurs, i.e. a sequence of bytes that do not correspond to a valid multibyte character are encountered. The value of the EILSEQ macro is stored in errno, and the conversion state is undefined.


Number of bytes in the converted multibyte string



otherwise. The terminating null character, if any, is not included in the count.

See also

mblen, mbtowc, wcstombs, wctomb