unitok

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 <unilib.h> 
   
  unicode_t *unitok (
     unicode_t          *string,
     const unicode_t    *sepset);
  

Parameters

string

(IN) Points to the string to parse. On subsequent calls, must be set to NULL.

sepset

(IN) Points to a null-terminated set of delimiter values. This string might be different from call to call.

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 unitok function considers the string pointed to by the string parameter to consist of a sequence of zero or more text tokens, separated from the delimiter pointed to by the sepset parameter by spans of one or more characters.

The first call to unitok returns a pointer to the first character of the first token in the string parameter and writes a null-terminating character into the string parameter immediately following the returned token. The unitok function sets the string parameter to a NULL pointer, which allows unitok, on subsequent calls, to search through the string and return successive tokens, until no tokens remain. Because unitok can modify the original string, that string should be duplicated if the string is to be reused.

The unitok function corresponds to the strtok function.

NOTE:For error-free, thread-safe operation, use the unitok_r function.

See Also