Name
wcsrtombs function — Converts a wide string to a multibyte string
Synopsis
size_t wcsrtombs(char* dst, const wchar_t** src, size_t len, mbstate_t* ps)
The wcsrtombs
function
converts a wide string to a string of multibyte characters. The
src
parameter points indirectly
to the source wide string, that is, *src
points to the start of the wide
string.
If dst
is not null, up to
len
bytes are stored in dst
. If fewer than len
bytes are stored, a trailing null
character is appended to the narrow character array. If conversion
stops upon reaching a null wide character in the src
string, a null
pointer is assigned to *src
; otherwise, *src
is assigned a pointer to the
character immediately past the end of the last wide character
converted.
The dst
parameter can be
null, in which case no narrow characters are stored and *src
is not altered, but ps
is updated and the return value is the
same as it would be if dst
were
large enough to hold the entire converted string.
The ps
parameter points to
the shift state, which keeps track of the conversion state between
calls to wcsrtombs
. If ps
is null, an internal shift state is
used (which is similar to calling wcstombs
in <cstdlib>
). If the conversion ends
without a terminating null character in *src
, the shift state is reset to an
mbstate_t
initial state.
If any of the wide characters cannot be represented as a
multibyte character, static_cast<size_t>(-1)
is returned. Otherwise, the return value is the number of bytes successfully converted from wide ...
Get C++ In a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.