utf8tok_r

Breaks a string into a sequence of tokens, each of which is delimited by a character from another string.

Library:LibC
Service:Characters and Strings

Syntax

  #include <utf8.h> 
   
  utf8_t *utf8tok_r (
     utf8_t        *string,   
     const utf8_t  *sepset,
     utf8_t       **lasts);
  

Parameters

string

(IN) Points to a null-terminated string to be broken into a sequence of tokens.

sepset

(IN) Points to a null-terminated string that contains the delimiter characters.

lasts

(IN/OUT) Points to a user-defined pointer, which stores information necessary to continue scanning the string.

Return Values

If a delimiter is found, returns a pointer to the first byte of a token. On subsequent iterations if no delimiter is found, returns a NULL pointer.

If the string does not contain any of the delimiters specified in sepset, returns a pointer to the string. All of the string is considered to be a token.

Remarks

The utf8tok_r function is used to break the string pointed to by string into a sequence of tokens, each of which is delimited by a character from the string pointed to by sepset.

The utf8tok_r function returns a pointer to the first character of the first token, writes a null-terminating character into the original string immediately following the returned token, and updates the pointer to which the lasts parameter points.

In order to get the next token in the string, all subsequent calls to utf8tok_r must pass a NULL pointer as the first argument and leave the lasts parameter unchanged.

The set of delimiters used each time utf8tok_r is called can be different from one call to the next.

Because utf8tok_r modifies the original string, make a copy of the string if you want to reuse it.

See Also