Standard C++ Library Reference ISO/IEC (VERSION3)
mbsinit
int mbsinit(const mbstate_t *ps);
The function returns a nonzero value if ps is a null pointer or if *ps designates an initial conversion state.
Otherwise, it returns zero.
mbsrtowcs
size_t mbsrtowcs(wchar_t *dst, const char **src,
size_t len, mbstate_t *ps);
The function converts the multibyte string beginning at *src to a sequence of wide characters as if by
repeated calls of the form:
x = mbrtowc(dst, *src, n, ps != 0 ? ps : &internal)
where n is some value > 0 and internal is an object of type mbstate_t internal to the mbsrtowcs
function. At program startup, internal is initialized to the initial conversion state. No other library
function alters the value stored in internal.
If dst is not a null pointer, the mbsrtowcs function stores at most len wide characters by calls to
mbrtowc. The function effectively increments dst by one and *src by x after each call to mbrtowc
that stores a converted wide character. After a call that returns zero, mbsrtowcs stores a null wide
character at dst and stores a null pointer at *src.
If dst is a null pointer, len is effectively assigned a large value.
The function returns:
(size_t)-1, if a call to mbrtowc returns (size_t)-1, indicating that it has detected an
encoding error before completing the next multibyte character
●
the number of multibyte characters successfully converted, not including the terminating null
character
●
mbstate_t
typedef o-type mbstate_t;
The type is an object type o-type that can represent a conversion state for any of the functions mbrlen,
mbrtowc, mbsrtowcs, wcrtomb, or wcsrtombs. A definition of the form:
mbstate_t mbst = {0};
ensures that mbst represents the initial conversion state. Note, however, that other values stored in an
object of type mbstate_t can also represent this state. To test safely for this state, use the function
mbsinit.