|
safec
3.1
Safe C Library - ISO TR24731 Bounds Checking Interface
|
#include "safe_str_lib.h"
Include dependency graph for wcstombs_s.c:Functions | |
| EXPORT errno_t | wcstombs_s (size_t *restrict retval, char *restrict dest, rsize_t dmax, const wchar_t *restrict src, rsize_t len) |
The wcstombs_s function converts a sequence of wide characters from the array whose first element is pointed to by src to to its narrow multibyte representation from the current LC_CTYPE locale. More... | |
| EXPORT errno_t wcstombs_s | ( | size_t *restrict | retval, |
| char *restrict | dest, | ||
| rsize_t | dmax, | ||
| const wchar_t *restrict | src, | ||
| rsize_t | len | ||
| ) |
The wcstombs_s function converts a sequence of wide characters from the array whose first element is pointed to by src to to its narrow multibyte representation from the current LC_CTYPE locale.
If dest is not null, converted characters are stored in the successive elements of dest. No more than len bytes are written to the destination array. Each wide character is converted as if by a call to wcrtomb. wcstombs_s clobbers the destination array from the terminating null and until dmax.
The conversion stops if:
L'\0' was converted and stored. The bytes stored in this case are the unshift sequence (if necessary) followed by '\0'.wchar_t was found that does not correspond to a valid character in the current LC_CTYPE locale.len. This condition is not checked if dst==NULL.With SAFECLIB_STR_NULL_SLACK defined all elements following the terminating null character (if any) written in the array of dmax characters pointed to by dest are nulled. Also in the error cases for src = NULL, ESNOSPC and EILSEQ.
| [out] | retval | the number of characters converted |
| [out] | dest | buffer for the resulting converted multibyte character string |
| [in] | dmax | The size in bytes of dest |
| [in] | src | wide string that will be converted to dest |
| [in] | len | number of bytes to be stored in dest, not including the terminating null character. |
retval and src shall not be a null pointer. RSIZE_MAX_STR (unless dest is null). dmax shall not equal zero (unless dest is null). dmax shall be greater than len. dest is not a null pointer and dmax is greater than zero and not greater than RSIZE_MAX_STR, then wcstombs_s nulls dest. Then the number of bytes excluding terminating zero that were, or would be written to dest, is stored in *retval. | EOK | on successful conversion. |
| ESNULLP | when retval or src are a NULL pointer |
| ESZEROL | when dmax = 0, unless dest is NULL |
| ESLEMAX | when dmax > RSIZE_MAX_STR, unless dest is NULL |
| ESOVRLP | when src and dest overlap |
| ESNOSPC | when there is no null character in the first dmax multibyte characters in the src array and len is greater than dmax (unless dest is null) |
| EILSEQ | if returned by wcstombs() |