wcsrtombs

Converts a sequence of wide characters into a sequence of corresponding multibyte characters.

Format

#include  <wchar.h>

size_t wcsrtombs  (char *dst, const wchar_t **src,
                  size_t len, mbstate_t *ps);
Function Variants This function also has variants named _wcsrtombs32 and _wcsrtombs64 for use with 32-bit and 64-bit pointer sizes, respectively. See Section 1.8 for more information on using pointer-size-specific functions.

Arguments

dst
A pointer to the destination array for converted multibyte character sequence.
src
An address of the pointer to an array containing the sequence of wide characters to be converted.
len
The maximum number of bytes that can be stored in the array pointed to by dst.
ps
A pointer to the mbstate_t object. If a NULL pointer is specified, the function uses its internal mbstate_t object.

Description

This function converts a sequence of wide characters from the array indirectly pointed to by src into a sequence of corresponding multibyte characters, beginning in the conversion state described by the object pointed to by ps.

If dst is a not NULL pointer, the converted characters are then stored into the array pointed to by dst. Conversion continues up to and including a terminating null wide character, which is also stored.

Conversion stops earlier in two cases:

Each conversion takes place as if by a call to the wcrtomb function.

If dst is not a NULL pointer, the pointer object pointed to by src is assigned either a NULL pointer, (if the conversion stopped because it reached a terminating null wide character) or the address just beyond the last wide character converted (if any). If conversion stopped because it reached a terminating null wide character, the resulting state described is the initial conversion state.

If the wcsrtombs function is called as a counting function, which means that dst is a NULL pointer, the value of the internal mbstate_t object will remain unchanged.

See also wcrtomb in this section.

Return Values
The number of bytes stored in the resulting array, not including the terminating null (if any). 
-1  Indicates an encoding error-a character that does not correspond to a valid multibyte character was encountered; errno is set to EILSEQ; the conversion state is undefined. 


Previous Page | Next Page | Table of Contents | Index