|WCSLCPY(3)||Library Functions Manual||WCSLCPY(3)|
— size-bounded wide string copying and
*dst, const wchar_t
*dst, const wchar_t
wcslcat() functions copy and concatenate wide
strings respectively. They are designed to be safer, more consistent, and
less error prone replacements for
wcsncat(3). Unlike those functions,
the full size of the buffer (not just the length) and guarantee to terminate
the result with a null wide character (as long as size
is larger than 0 or, in the case of
long as there is at least one wide character free in
dst). Note that a wide character for the null wide
character should be included in size. Also note that
operate on wide strings that are terminated with a null wide character
(L'\0'). This means that for
src must be terminated with a null wide character and
wcslcat() both src and
dst must be terminated with a null wide character.
function copies up to size − 1 wide characters
from the wide string src to dst,
terminating the result with a null wide character.
function appends the wide string src to the end of
dst. It will append at most size
− wcslen(dst) − 1 wide characters, terminating the result with
a null wide character.
If the src and dst strings overlap, the behavior is undefined.
wcslcat() functions return the total length of the
wide string they tried to create. For
means the length of src. For
wcslcat() that means the initial length of
dst plus the length of src.
While this may seem somewhat confusing, it was done to make truncation
Note, however, that if
size wide characters without finding a null wide
character, the length of the string is considered to be
size and the destination wide string will not be
terminated with a null wide character (since there was no space for it).
wcslcat() from running off the end of a
wide string. In practice this should not happen (as it means that either
size is incorrect or that dst is
not terminated with a null wide character). The check exists to prevent
potential security problems in incorrect code.
wcslcat() functions first appeared in
wcslcat() functions are based on code by
Todd C. Miller
|January 25, 2019||OpenBSD-current|