1WCSTOK(3)                  Linux Programmer's Manual                 WCSTOK(3)
2
3
4

NAME

6       wcstok - split wide-character string into tokens
7

SYNOPSIS

9       #include <wchar.h>
10
11       wchar_t *wcstok(wchar_t *restrict wcs, const wchar_t *restrict delim,
12                       wchar_t **restrict ptr);
13

DESCRIPTION

15       The wcstok() function is the wide-character equivalent of the strtok(3)
16       function, with an added argument to make it multithread-safe.   It  can
17       be used to split a wide-character string wcs into tokens, where a token
18       is defined as a substring not containing any wide-characters  from  de‐
19       lim.
20
21       The  search  starts  at  wcs, if wcs is not NULL, or at *ptr, if wcs is
22       NULL.  First, any delimiter wide-characters are skipped, that  is,  the
23       pointer  is  advanced  beyond any wide-characters which occur in delim.
24       If the end of the wide-character string is now  reached,  wcstok()  re‐
25       turns NULL, to indicate that no tokens were found, and stores an appro‐
26       priate value in *ptr, so that subsequent calls to  wcstok()  will  con‐
27       tinue  to return NULL.  Otherwise, the wcstok() function recognizes the
28       beginning of a token and returns a pointer  to  it,  but  before  doing
29       that, it zero-terminates the token by replacing the next wide-character
30       which occurs in delim with a null wide character (L'\0'),  and  it  up‐
31       dates  *ptr  so that subsequent calls will continue searching after the
32       end of recognized token.
33

RETURN VALUE

35       The wcstok() function returns a pointer to the next token, or  NULL  if
36       no further token was found.
37

ATTRIBUTES

39       For  an  explanation  of  the  terms  used  in  this  section,  see at‐
40       tributes(7).
41
42       ┌────────────────────────────────────────────┬───────────────┬─────────┐
43Interface                                   Attribute     Value   
44       ├────────────────────────────────────────────┼───────────────┼─────────┤
45wcstok()                                    │ Thread safety │ MT-Safe │
46       └────────────────────────────────────────────┴───────────────┴─────────┘
47

CONFORMING TO

49       POSIX.1-2001, POSIX.1-2008, C99.
50

NOTES

52       The original wcs wide-character string is destructively modified during
53       the operation.
54

EXAMPLES

56       The  following code loops over the tokens contained in a wide-character
57       string.
58
59       wchar_t *wcs = ...;
60       wchar_t *token;
61       wchar_t *state;
62       for (token = wcstok(wcs, " \t\n", &state);
63           token != NULL;
64           token = wcstok(NULL, " \t\n", &state)) {
65           ...
66       }
67

SEE ALSO

69       strtok(3), wcschr(3)
70

COLOPHON

72       This page is part of release 5.12 of the Linux  man-pages  project.   A
73       description  of  the project, information about reporting bugs, and the
74       latest    version    of    this    page,    can     be     found     at
75       https://www.kernel.org/doc/man-pages/.
76
77
78
79GNU                               2021-03-22                         WCSTOK(3)
Impressum