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 *wcs, const wchar_t *delim, wchar_t **ptr);
12

DESCRIPTION

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

RETURN VALUE

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

ATTRIBUTES

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

CONFORMING TO

47       POSIX.1-2001, POSIX.1-2008, C99.
48

NOTES

50       The original wcs wide-character string is destructively modified during
51       the operation.
52

EXAMPLE

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

SEE ALSO

67       strtok(3), wcschr(3)
68

COLOPHON

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