wcsrtombs, wcsrtombs_s
From cppreference.com
Defined in header <wchar.h>
|
||
(1) | ||
(since C95) (until C99) |
||
(since C99) | ||
(2) | (since C11) | |
1) Converts a sequence of wide characters from the array whose first element is pointed to by *src to its narrow multibyte representation that begins in the conversion state described by *ps. If
dst
is not null, converted characters are stored in the successive elements of the char array pointed to by dst
. No more than len
bytes are written to the destination array. Each character is converted as if by a call to wcrtomb. The conversion stops if:
- The null character L'\0' was converted and stored. The bytes stored in this case are the unshift sequence (if necessary) followed by '\0', *src is set to null pointer value and *ps represents the initial shift state.
- A wchar_t was found that does not correspond to a valid character in the current C locale. *src is set to point at the first unconverted wide character.
- the next multibyte character to be stored would exceed
len
. *src is set to point at the first unconverted wide character. This condition is not checked ifdst
is a null pointer.
2) Same as (1), except that
- the function returns its result as an out-parameter
retval
- if the conversion stops without writing a null character, the function will store '\0' in the next byte in
dst
, which may be dst[len] or dst[dstsz], whichever comes first (meaning up to len+1/dstsz+1 total bytes may be written). In this case, there may be no unshift sequence written before the terminating null. - the function clobbers the destination array from the terminating null and until
dstsz
- If
src
anddst
overlap, the behavior is unspecified. - the following errors are detected at runtime and call the currently installed constraint handler function:
-
retval
,ps
,src
, or *src is a null pointer -
dstsz
orlen
is greater than RSIZE_MAX (unlessdst
is null) -
dstsz
is not zero (unlessdst
is null) -
len
is greater thandstsz
and the conversion does not encounter null or encoding error in thesrc
array by the timedstsz
is reached (unlessdst
is null)
-
- As with all bounds-checked functions,
wcsrtombs_s
is only guaranteed to be available if __STDC_LIB_EXT1__ is defined by the implementation and if the user defines __STDC_WANT_LIB_EXT1__ to the integer constant 1 before including <wchar.h>.
Contents |