The vswprintf_s function composes a wide string with same test that would be printed if format was used on wprintf.
Instead of being printed, the content is stored in dest. With SAFECLIB_STR_NULL_SLACK defined all elements following the terminating NUL character (if any) written by vswprintf_s in the array of dmax wide characters pointed to by dest are nulled when vswprintf_s returns.
- Parameters
-
| [out] | dest | pointer to wide string that will be written into. |
| [in] | dmax | restricted maximum length of dest |
| [in] | fmt | format-control wide string. |
| [in] | ap | optional arguments |
- Precondition
- Neither dest nor fmt shall be a null pointer.
-
dmax shall not be greater than RSIZE_MAX_WSTR.
-
dmax shall not equal zero.
-
dmax shall be greater than wcsnlen_s(dest, dmax).
-
fmt shall not contain the conversion specifier
n
-
None of the arguments corresponding to
s is a null pointer (not yet)
-
No encoding error shall occur.
- Note
- C11 uses RSIZE_MAX, not RSIZE_MAX_WSTR.
- Returns
- If no runtime-constraint violation occurred, the vswprintf_s function returns the number of wide characters written in the array, not counting the terminating null wide character. If an encoding error occurred or if n or more wide characters are requested to be written, vswprintf_s returns a negative value. If any other runtime-constraint violation occurred, vswprintf_s returns zero.
-
If the buffer dest is too small for the formatted text, including the terminating null, then the buffer is set to an empty string by placing a null wide character at dest[0], and the invalid parameter handler is invoked. Unlike vsnprintf, vswprintf_s guarantees that the buffer will be null-terminated unless the buffer size is zero.
- Return values
-
| >0 | on success |
| -ESNULLP | when dest/fmt is NULL pointer |
| -ESZEROL | when dmax = 0 |
| -ESLEMAX | when dmax > RSIZE_MAX_WSTR |
| -EOVERFLOW | when dmax > size of dest |
| -ESNOSPC | when return value exceeds dmax |
| -EINVAL | when fmt contains n |
| -1 | if an encoding error occurred or if n or more wide characters are requested to be written. |
| 0 | on some other error |
- See also
- sprintf_s(), vsnprintf_s(), swprintf_s()