Your Browser is not longer supported

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

{{viewport.spaceProperty.prod}}

mbsrtowcs - Convert multibyte string to wide character string

&pagelevel(4)&pagelevel

Definition

#include <wchar.h>

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

mbsrtowcs converts a sequence of multibyte 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 wide 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 mbrtowc 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 is encountered that does not form a valid multibyte character
    or

  • if dst is not a null pointer, when len codes have been stored into the array pointed to by
    dst.

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 multibyte character converted (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 form a valid
multibyte character are encountered. The value of the EILSEQ macro is
stored in errno, and the conversion state is undefined.

Number of successfully converted multibyte chatacters

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

See also

mblen, mbtowc, wcstombs, wctomb