svcadm(8)을 검색하려면 섹션에서 8 을 선택하고, 맨 페이지 이름에 svcadm을 입력하고 검색을 누른다.
wcsdup(3c)
wcstring(3C) Standard C Library Functions wcstring(3C)
NAME
wcstring, wcscasecmp, wcsncasecmp, wcscat, wscat, wcsncat, wsncat, wc‐
scmp, wscmp, wcsncmp, wsncmp, wcscpy, wscpy, wcsncpy, wsncpy, wcpcpy,
wcpncpy, wcsdup, wcslen, wslen, wcsnlen, wcschr, wschr, wcsrchr, ws‐
rchr, windex, wrindex, wcspbrk, wspbrk, wcsspn, wsspn, wcscspn, wscspn,
wcstok, wstok, wcscpy_s, wcsncpy_s, wcscat_s, wcsncat_s, wcstok_s, wc‐
snlen_s - wide-character string operations
SYNOPSIS
#include <wchar.h>
int wcscasecmp(const wchar_t *ws1, const wchar_t *ws2);
int wcsncasecmp(const wchar_t *ws1, const wchar_t *ws2, size_t n);
wchar_t *wcscat(wchar_t *ws1, const wchar_t *ws2);
wchar_t *wcsncat(wchar_t *restrict ws1, const wchar_t *restrict ws2,
size_t n);
int wcscmp(const wchar_t *ws1, const wchar_t *ws2);
int wcsncmp(const wchar_t *ws1, const wchar_t *ws2, size_t n);
wchar_t *wcscpy(wchar_t *restrict ws1, const wchar_t *restrict ws2);
wchar_t *wcsncpy(wchar_t *restrict ws1, const wchar_t *restrict ws2,
size_t n);
wchar_t *wcpncpy(wchar_t *restrict ws1, const wchar_t *restrict ws2,
size_t n);
wchar_t *wcsdup(const wchar_t *s);
size_t wcslen(const wchar_t *ws);
size_t wcsnlen(const wchar_t *ws, size_t maxlen);
wchar_t *wcschr(const wchar_t *ws, wchar_t wc);
wchar_t *wcsrchr(const wchar_t *ws, wchar_t wc);
wchar_t *wcspbrk(const wchar_t *ws1, const wchar_t *ws2);
size_t wcsspn(const wchar_t *ws1, const wchar_t *ws2);
size_t wcscspn(const wchar_t *ws1, const wchar_t *ws2);
#include <wchar.h>
const wchar_t *wcschr(const wchar_t *ws, wchar_t wc);
const wchar_t *wcspbrk(const wchar_t *ws1, const wchar_t *ws2);
const wchar_t *wcsrchr(const wchar_t *ws, wchar_t wc);
#define __STDC_WANT_LIB_EXT1__ 1
#include <wchar.h>
errno_t wcscpy_s(wchar_t *restrict ws1, rsize_t ws1max,
const wchar_t *restrict ws2);
errno_t wcsncpy_s(wchar_t *restrict ws1, rsize_t ws1max,
const wchar_t *restrict ws2, rsize_t n);
errno_t wcscat_s(wchar_t *restrict ws1, rsize_t ws1max,
const wchar_t *restrict ws2);
errno_t wcsncat_s(wchar_t *restrict ws1, rsize_t ws1max,
const wchar_t *restrict ws2, rsize_t n);
wchar_t *wcstok_s(wchar_t *restrict ws1, rsize_t *restrict ws1max,
const wchar_t *restrict ws2, wchar_t **restrict ptr);
size_t wcsnlen_s(const wchar_t *ws, size_t maxsize);
ISO C++
#include <cwchar>
wchar_t *std::wcschr(wchar_t *ws, wchar_t wc);
wchar_t *std::wcspbrk(wchar_t *ws1, const wchar_t *ws2);
wchar_t *std::wcsrchr(wchar_t *ws, wchar_t wc);
XPG4, SUS
wchar_t *wcstok(wchar_t * ws1, const wchar_t * ws2);
Default and other standards
wchar_t *wcstok(wchar_t * restrict ws1, const wchar_t * restrict ws2,
wchar_t ** restrict ptr);
#include <widec.h>
wchar_t *wscat(wchar_t *ws1, const wchar_t *ws2);
wchar_t *wsncat(wchar_t *ws1, const wchar_t *ws2, size_t n);
int wscmp(const wchar_t *ws1, const wchar_t *ws2);
int wsncmp(const wchar_t *ws1, const wchar_t *ws2, size_t n);
wchar_t *wscpy(wchar_t *ws1, const wchar_t *ws2);
wchar_t *wsncpy(wchar_t *ws1, const wchar_t *ws2, size_t n);
size_t wslen(const wchar_t *ws);
wchar_t *wschr(const wchar_t *ws, wchat_t wc);
wchar_t *wsrchr(const wchar_t *ws, wchat_t wc);
wchar_t *wspbrk(const wchar_t *ws1, const wchar_t *ws2);
size_t wsspn(const wchar_t *ws1, const wchar_t *ws2);
size_t wscspn(const wchar_t *ws1, const wchar_t *ws2);
wchar_t *wstok(wchar_t *ws1, const wchar_t *ws2);
wchar_t *windex(const wchar_t *ws, wchar_t wc);
wchar_t *wrindex(const wchar_t *ws, wchar_t wc);
DESCRIPTION
These functions operate on wide-character strings terminated by wchar_t
NULL characters. During appending or copying, these routines do not
check for an overflow condition of the receiving string. In the follow‐
ing, ws, ws1, and ws2 point to wide-character strings terminated by a
wchar_t NULL.
wcscasecmp(), wcsncasecmp()
The wcscasecmp() function is the wide-character equivalent of the str‐
casecmp(3C) function. It compares the wide-character string pointed to
by ws1 to the wide-character string pointed to by ws2, ignoring case
differences. It returns 0 if the wide-character strings at ws1 and ws2
are equal except for case differences. It returns a positive integer if
ws1 is greater than ws2 and a negative integer if ws1 is smaller than
ws2, ignoring case.
The wcsncasecmp() function is the wide-character equivalent of the
strncasecmp(3C) function. It compares at most n wide-characters from
the wide-character string pointed to by ws1 to the wide-character
string pointed to by ws2, while ignoring differences in case. It re‐
turns 0 if the wide-character strings at ws1 and ws2, truncated to at
most length n, are equal except for case distinctions. It returns a
positive integer if truncated ws1 is greater than ws2 and a negative
integer if truncated ws1 is smaller than ws2, ignoring case.
wcscat(), wscat()
The wcscat() and wscat() functions append a copy of the wide-character
string pointed to by ws2 (including the terminating null wide-character
code) to the end of the wide-character string pointed to by ws1. The
initial wide-character code of ws2 overwrites the null wide-character
code at the end of ws1. If copying takes place between objects that
overlap, the behavior is undefined. Both functions return s1; no return
value is reserved to indicate an error.
wcsncat(), wsncat()
The wcsncat() and wsncat() functions append not more than n wide-char‐
acter codes (a null wide-character code and wide-character codes that
follow it are not appended) from the array pointed to by ws2 to the end
of the wide-character string pointed to by ws1. The initial wide-char‐
acter code of ws2 overwrites the null wide-character code at the end of
ws1. A terminating null wide-character code is always appended to the
result. Both functions return ws1; no return value is reserved to indi‐
cate an error.
wcscmp(), wscmp()
The wcscmp() and wscmp() functions compare the wide-character string
pointed to by ws1 to the wide-character string pointed to by ws2. The
sign of a non-zero return value is determined by the sign of the dif‐
ference between the values of the first pair of wide-character codes
that differ in the objects being compared. Upon completion, both func‐
tions return an integer greater than, equal to, or less than zero, if
the wide-character string pointed to by ws1 is greater than, equal to,
or less than the wide-character string pointed to by ws2.
wcsncmp(), wsncmp()
The wcsncmp() and wsncmp() functions compare not more than n wide-char‐
acter codes (wide-character codes that follow a null wide character
code are not compared) from the array pointed to by ws1 to the array
pointed to by ws2. The sign of a non-zero return value is determined by
the sign of the difference between the values of the first pair of
wide-character codes that differ in the objects being compared. Upon
successful completion, both functions return an integer greater than,
equal to, or less than zero, if the possibly null-terminated array
pointed to by ws1 is greater than, equal to, or less than the possibly
null-terminated array pointed to by ws2.
wcscpy(), wscpy(), wcpcpy()
The wcscpy(), wscpy(), and wcpcpy() functions copy the wide-character
string pointed to by ws2 (including the terminating null wide-character
code) into the array pointed to by ws1. If copying takes place between
objects that overlap, the behavior is undefined.
The wcscpy() and wscpy() functions return ws1. The wcpcpy() function
returns a pointer to the terminating null wide-character code copied
into ws1.
wcsncpy(), wsncpy(), wcpncpy()
The wcsncpy(), wsncpy(), and wcpncpy() functions copy not more than n
wide-character codes (wide-character codes that follow a null wide
character code are not copied) from the array pointed to by ws2 to the
array pointed to by ws1. If copying takes place between objects that
overlap, the behavior is undefined.
If the array pointed to by ws2 is a wide-character string that is
shorter than n wide-character codes, null wide-character codes are ap‐
pended to the copy in the array pointed to by ws1, until a total n
wide-character codes are written. The wcsncpy() and wsncpy() functions
return ws1. The wcpncpy() function returns a pointer to the last wide
character written.
wcsdup()
The wcsdup() function is the wide-character equivalent of the
strdup(3C) function. It returns a pointer to a new wide-character
string whose initial contents is a duplicate of the wide-character
string pointed to by s. Memory for the new wide-character string is al‐
located with malloc(3C) and can be freed with a call to free(3C). A
null pointer is returned and errno set to ENOMEM if there is insuffi‐
cient memory available for the duplicate string.
wcslen(), wslen(), wcsnlen()
The wcslen() and wslen() functions compute the number of wide-character
codes in the wide-character string to which ws points, not including
the terminating null wide-character code. Both functions return ws; no
return value is reserved to indicate an error.
The wcsnlen() is the wide-character equivalent of the strnlen(3C) func‐
tion. It returns the number of wide-characters in the string pointed to
by ws, not including the terminating null wide-character code but at
most maxlen, while never looking beyond the first maxlen characters. It
returns maxlen if there is no terminating null wide-character code
among the first maxlen wide characters pointed to by ws.
wcschr(), wschr()
The wcschr() and wschr() functions locate the first occurrence of wc in
the wide-character string pointed to by ws. The value of wc must be a
character representable as a type wchar_t and must be a wide-character
code corresponding to a valid character in the current locale. The ter‐
minating null wide-character code is considered to be part of the wide-
character string. Upon completion, both functions return a pointer to
the wide-character code, or a null pointer if the wide-character code
is not found.
wcsrchr(), wsrchr()
The wcsrchr() and wsrchr() functions locate the last occurrence of wc
in the wide-character string pointed to by ws. The value of wc must be
a character representable as a type wchar_t and must be a wide-charac‐
ter code corresponding to a valid character in the current locale. The
terminating null wide-character code is considered to be part of the
wide-character string. Upon successful completion, both functions re‐
turn a pointer to the wide-character code, or a null pointer if wc does
not occur in the wide-character string.
windex(), wrindex()
The windex() and wrindex() functions behave the same as wschr() and ws‐
rchr(), respectively.
wcspbrk(), wspbrk()
The wcspbrk() and wspbrk() functions locate the first occurrence in the
wide character string pointed to by ws1 of any wide-character code from
the wide-character string pointed to by ws2. Upon successful comple‐
tion, the function returns a pointer to the wide-character code, or a
null pointer if no wide-character code from ws2 occurs in ws1.
wcsspn(), wsspn()
The wcsspn() and wsspn() functions compute the length of the maximum
initial segment of the wide-character string pointed to by ws1 which
consists entirely of wide-character codes from the wide-character
string pointed to by ws2. Both functions return the length of the ini‐
tial substring of ws1; no return value is reserved to indicate an er‐
ror.
wcscspn(), wscspn()
The wcscspn() and wscspn() functions compute the length of the maximum
initial segment of the wide-character string pointed to by ws1 which
consists entirely of wide-character codes not from the wide-character
string pointed to by ws2. Both functions return the length of the ini‐
tial substring of ws1; no return value is reserved to indicate an er‐
ror.
wcstok(), wstok()
A sequence of calls to the wcstok() and wstok() functions break the
wide-character string pointed to by ws1 into a sequence of tokens, each
of which is delimited by a wide-character code from the wide-character
string pointed to by ws2.
The XPG5 and later versions of wcstok() take a third argument which
points to a caller-provided wchar_t pointer into which the wcstok()
function stores information necessary for it to continue scanning the
same wide-character string. This argument is not available with the
XPG4 and SUS versions of wcstok(), nor is it available with the wstok()
function. See standards(7) for information on specifying which standard
to use for building code.
The first call in the sequence has ws1 as its first argument, and is
followed by calls with a null pointer as their first argument. The sep‐
arator string pointed to by ws2 may be different from call to call.
The first call in the sequence searches the wide-character string
pointed to by ws1 for the first wide-character code that is not con‐
tained in the current separator string pointed to by ws2. If no such
wide-character code is found, then there are no tokens in the wide-
character string pointed to by ws1, and wcstok() and wstok() return a
null pointer. If such a wide-character code is found, it is the start
of the first token.
The wcstok() and wstok() functions then search from that point for a
wide-character code that is contained in the current separator string.
If no such wide-character code is found, the current token extends to
the end of the wide-character string pointed to by ws1, and subsequent
searches for a token will return a null pointer. If such a wide-charac‐
ter code is found, it is overwritten by a null wide character, which
terminates the current token. The wcstok() and wstok() functions save a
pointer to the following wide-character code, from which the next
search for a token will start.
Each subsequent call, with a null pointer as the value of the first ar‐
gument, starts searching from the saved pointer and behaves as de‐
scribed above.
Upon successful completion, both functions return a pointer to the
first wide-character code of a token. Otherwise, if there is no token,
a null pointer is returned.
C11 Bounds Checking Interfaces
The wcscpy_s(), wcsncpy_s(), wcscat_s(), wcsncat_s(), wcstok_s(), and
wcsnlen_s() functions are part of the C11 bounds checking interfaces
specified in the C11 standard, Annex K. Each provides similar function‐
ality to their respective non-bounds checking functions, except for ad‐
ditional checks on the parameters passed and explicit runtime con‐
straints as defined in the C11 standard. See runtime_constraint_han‐
dler(3C) and INCITS/ISO/IEC 9899:2011.
If no runtime constraint violation is detected, the wcscpy_s(), wc‐
sncpy_s(), wcscat_s(), and wcsncat(), and wcrtomb_s() functions return
zero, otherwise, they return a non-zero value.
If a runtime constraint violation is detected, or there is no token,
the wcstok_s() function returns a null pointer, otherwise a pointer to
the first wide character of the token is returned.
The wcsnlen_s() function returns zero if ws is a null pointer. Other‐
wise, it returns the number of wide-characters in the string pointed to
by ws, not including the terminating null wide-character code but at
most maxlen, while never looking beyond the first maxlen characters. It
returns maxlen if there is no terminating null wide-character code
among the first maxlen wide characters pointed to by ws.
ERRORS
The functions wcscpy_s(), wcsncpy_s(), wcscat_s(), and wcstok_s() will
fail if:
EINVAL Null pointer is passed or Source and destination overlap.
ERANGE size argument is not a valid value.
EOVERFLOW Destination array is too small.
The function wcsncat_s() will fail if:
EINVAL Null pointer is passed.
ERANGE size argument is not a valid value.
USAGE
The functions provided in <widec.h> (those with names starting with
just "w" instead of "wc") are provided for backwards compatibility, and
are not recommended for use in newer code. Instead, the equivalent
functions from <wchar.h> should be used for greater portability to
other systems.
tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) LEGACY FUNCTION‐
PREFERRED ALTERNATIVE _ wscat()wcscat() _ wsncat()wcsncat() _
wscmp()wcscmp() _ wsncmp()wcsncmp() _ wscpy()wcscpy() _ wsncpy()wc‐
sncpy() _ wslen()wcslen() _ wschr()wcschr() _ wsrchr()wcsrchr() _
windex()wcschr() _ wrindex()wcsrchr() _ wspbrk()wcspbrk() _ wsspn()wc‐
sspn() _ wstok()wcstok()
ATTRIBUTES
See attributes(7) for descriptions of the following attributes:
tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) ATTRIBUTE TYPEAT‐
TRIBUTE VALUE _ CSIEnabled _ Interface StabilityCommitted _ MT-LevelSee
below _ StandardSee below
MT-Level
The wcscasecmp(), wcsncasecmp(), wcscat(), wscat(), wcsncat(), ws‐
ncat(), wcscmp(), wscmp(), wcsncmp(), wsncmp(), wcscpy(), wscpy(), wc‐
sncpy(), wsncpy(), wcpcpy(), wcpncpy(), wcslen(), wslen(), wcsnlen(),
wcschr(), wschr(), wcsrchr(), wsrchr(), windex(), wrindex(), wcspbrk(),
wspbrk(), wcsspn(), wsspn(), wcscspn(), and wscspn() functions are
Async-Signal-Safe.
The wcsdup() function is MT-Safe.
The version of wcstok() that takes three arguments is Async-Signal-
Safe, while the version that takes only two arguments is not. The
wstok() function and the two-argument form of wcstok() store state in
thread-specific data, so are safe to use in a multi-threaded program,
but calls from different threads will not share common state.
The wcscpy_s(), wcsncpy_s(), wcscat_s(), wcsncat_s(), wcstok_s(), wc‐
snlen_s(), and wcrtomb_s() functions cannot be used safely in a multi‐
threaded application due to the runtime constraint handler. For more
information, see the runtime_constraint_handler(3C) man page.
Standard
See standards(7) for descriptions of the following standards:
tab() box; cw(2.44i) |cw(3.06i) lw(2.44i) |lw(3.06i) INTERFACESAPPLICA‐
BLE STANDARDS _ T{ wcscat(), wcsncat(), wcscmp(), wcsncmp(), wcscpy(),
wcsncpy(), wcslen(), wcschr(), wcsrchr(), wcspbrk(), wcsspn(),
wcscspn(), wcstok() T}T{
C95 through C11,
POSIX.1-2001 through 2008,
SUS through SUSv4,
XPG4 through XPG7
T} _ T{ wcscasecmp(), wcsncasecmp(), wcpcpy(), wcpncpy(), wcsdup(),
wcsnlen() T}T{
POSIX.1-2008,
SUSv4,
XPG7
T} _ T{ wcscpy_s(), wcsncpy_s(), wcscat_s(), wcsncat_s(), wcstok_s(),
wcsnlen_s(), wcrtomb_s() T}T{
C11
T} _ T{ wscat(), wsncat(), wscmp(), wsncmp(), wscpy(), wsncpy(),
wslen(), wschr(), wsrchr(), windex(), wrindex(), wspbrk(), wsspn(),
wstok() T}T{
None
T}
SEE ALSO
malloc(3C), string(3C), wcsstr(3C), wcswidth(3C), wcwidth(3C), attrib‐
utes(7), standards(7), runtime_constraint_handler(3C)
Handling Characters and Character Strings in Internationalizing and Lo‐
calizing Applications in Oracle Solaris
HISTORY
Support for the following functions is available in Oracle Solaris
starting with the listed release:
tab() box; cw(4.71i) |cw(0.79i) lw(4.71i) |lw(0.79i) FUNCTIONRELEASE _
T{ wcscat_s(), wcsncat_s(), wcscpy_s(), wcsncpy_s(), wcsnlen_s(),
wcstok_s() T}11.4.0 _ T{ wcpcpy(), wcpncpy(), wcsncasecmp(), wcsdup(),
wcsnlen() T}11.0.0 _ wcscasecmp()7 _ T{ wcscat(), wcsncat(), wcschr(),
wcsrchr(), wcscmp(), wcsncmp(), wcscpy(), wcsncpy(), wcslen(),
wcspbrk(), wcsspn(), wcscspn(), wcstok() T}2.4 _ T{ windex(),
wrindex(), wscat(), wsncat(), wschr(), wsrchr(), wscmp(), wsncmp(),
wscpy(), wsncpy(), wslen(), wspbrk(), wsspn(), wscspn(), wstok() T}2.0
In Solaris 2.0 through 2.5, these functions were located in the libw
library. In Solaris 2.6 and later, they are located in libc, and the
libw library is a filter on libc to maintain binary and source compati‐
bility.
Oracle Solaris 11.4 25 Nov 2024 wcstring(3C)