]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/wcstok.3
Many pages: Use correct letter case in page titles (TH)
[thirdparty/man-pages.git] / man3 / wcstok.3
CommitLineData
fea681da
MK
1.\" Copyright (c) Bruno Haible <haible@clisp.cons.org>
2.\"
e4a74ca8 3.\" SPDX-License-Identifier: GPL-2.0-or-later
fea681da
MK
4.\"
5.\" References consulted:
6.\" GNU glibc-2 source code and manual
7.\" Dinkumware C library reference http://www.dinkumware.com/
008f1ecc 8.\" OpenGroup's Single UNIX specification http://www.UNIX-systems.org/online.html
fea681da
MK
9.\" ISO/IEC 9899:1999
10.\"
4c1c5274 11.TH wcstok 3 (date) "Linux man-pages (unreleased)"
fea681da
MK
12.SH NAME
13wcstok \- split wide-character string into tokens
21a12069
AC
14.SH LIBRARY
15Standard C library
8fc3b2cf 16.RI ( libc ", " \-lc )
fea681da
MK
17.SH SYNOPSIS
18.nf
19.B #include <wchar.h>
68e4db0a 20.PP
21a4b17e
AC
21.BI "wchar_t *wcstok(wchar_t *restrict " wcs \
22", const wchar_t *restrict " delim ,
23.BI " wchar_t **restrict " ptr );
fea681da
MK
24.fi
25.SH DESCRIPTION
60a90ecd
MK
26The
27.BR wcstok ()
28function is the wide-character equivalent of the
29.BR strtok (3)
30function,
c13182ef 31with an added argument to make it multithread-safe.
35478399 32It can be used
40aa0db0
MK
33to split a wide-character string
34.I wcs
35into tokens, where a token is
36defined as a substring not containing any wide-characters from
37.IR delim .
fea681da 38.PP
40aa0db0
MK
39The search starts at
40.IR wcs ,
41if
42.I wcs
43is not NULL,
44or at
45.IR *ptr ,
46if
47.I wcs
48is NULL.
75b94dc3 49First, any delimiter wide-characters are skipped, that is, the
40aa0db0
MK
50pointer is advanced beyond any wide-characters which occur in
51.IR delim .
1c44bd5b 52If the end of the wide-character string is now
60a90ecd
MK
53reached,
54.BR wcstok ()
55returns NULL, to indicate that no tokens
40aa0db0
MK
56were found, and stores an appropriate value in
57.IR *ptr ,
60a90ecd
MK
58so that subsequent calls to
59.BR wcstok ()
60will continue to return NULL.
61Otherwise, the
62.BR wcstok ()
63function recognizes the beginning of a token
fea681da 64and returns a pointer to it, but before doing that, it zero-terminates the
40aa0db0
MK
65token by replacing the next wide-character which occurs in
66.I delim
67with
d1a71985 68a null wide character (L\(aq\e0\(aq),
40aa0db0
MK
69and it updates
70.I *ptr
71so that subsequent calls will
fea681da 72continue searching after the end of recognized token.
47297adb 73.SH RETURN VALUE
60a90ecd
MK
74The
75.BR wcstok ()
76function returns a pointer to the next token,
1c44bd5b 77or NULL if no further token was found.
2721cf12 78.SH ATTRIBUTES
54b8b922
PH
79For an explanation of the terms used in this section, see
80.BR attributes (7).
c466875e
MK
81.ad l
82.nh
54b8b922
PH
83.TS
84allbox;
c466875e 85lbx lb lb
54b8b922
PH
86l l l.
87Interface Attribute Value
88T{
2721cf12 89.BR wcstok ()
54b8b922
PH
90T} Thread safety MT-Safe
91.TE
c466875e
MK
92.hy
93.ad
94.sp 1
3113c7f3 95.SH STANDARDS
789a49fa 96POSIX.1-2001, POSIX.1-2008, C99.
fea681da 97.SH NOTES
40aa0db0
MK
98The original
99.I wcs
100wide-character string is destructively modified during
fea681da 101the operation.
a14af333 102.SH EXAMPLES
fea681da 103The following code loops over the tokens contained in a wide-character string.
bdd915e2
MK
104.PP
105.EX
fea681da
MK
106wchar_t *wcs = ...;
107wchar_t *token;
108wchar_t *state;
c61a1c39 109for (token = wcstok(wcs, L" \et\en", &state);
b9f02710 110 token != NULL;
c61a1c39 111 token = wcstok(NULL, L" \et\en", &state)) {
b9f02710 112 ...
fea681da 113}
bdd915e2 114.EE
47297adb 115.SH SEE ALSO
fea681da
MK
116.BR strtok (3),
117.BR wcschr (3)