MBSTOWCS(3C) Standard C Library Functions MBSTOWCS(3C)

mbstowcs, mbstowcs_lconvert a multibyte character string to a wide-character string

Standard C Library (libc, -lc)

#include <stdlib.h>

size_t
mbstowcs(wchar_t *restrict pwcs, const char *restrict s, size_t n);

#include <stdlib.h>
#include <xlocale.h>

size_t
mbstowcs_l(wchar_t *restrict pwcs, const char *restrict s, size_t n, locale_t loc);

The () function converts a multibyte character string s beginning in the initial conversion state into a wide-character string. If pwcs is not NULL, the converted characters are stored into array pointed to by pwcs.

Conversion continues up to and including a terminating null character, which is also stored, or until n wide-characters have been stored into the array pointed to by pwcs.

The behavior of () function is affected by the LC_CTYPE category of the current locale.

The () function behaves identically to mbstowcs(), except instead of using the current locale, it uses the locale as specified by loc.

The mbstowcs() and mbstowcs_l() functions return the number of wide-characters successfully converted, not including the terminating null (if any), or -1 if conversion encounters a sequence of bytes that does not form a valid character.

The mbstowcs() and mbstowcs_l() functions will fail if:

An invalid multibyte sequence was detected.
The conversion state is invalid.

The mbstowcs() function is . The mbstowcs_l() function is .

mbsnrtowcs(3C), mbtowc(3C), newlocale(3C), setlocale(3C), uselocale(3C), wcstombs(3C), attributes(7), environ(7), standards(7)

March 28, 2017 OmniOS