Internationalization and localization tools


Locale-Sensitive C/C++ String Operation Function

char *strsep(char **string_ptr, const char *delimiter);

Internationalization (I18n) Function Overview

This function has a similar functionality as strtok_r with the newstring argument replaced by the string_ptr argument. The initialization of the moving pointer has to be done by the user. Successive calls to strsep move the pointer along the tokens separated by delimiter, returning the address of the next token and updating string_ptr to point to the beginning of the next token.

One difference between strsep and strtok_r is that if the input string contains more than one character from delimiter in a row strsep returns an empty string for each pair of characters from delimiter. This means that a program normally should test for strsep returning an empty string before processing it.

I18n Issues

There is no ANSI multibyte UTF-8 version of this function, and strsep does not work correctly with multibyte UTF-8 characters. (In a string containing multibyte UTF-8 characters, characters consisting of more than one byte are not treated by strsep as an entity, each byte is treated separately.)

Additionally, there is no ANSI wide character version of this function.

These two issues combined mean that there is no suitable substitution for strsep that is readily available which supports both re-entrancy and either multibyte or wide character strings.

Recommended Replacements*

*If you're already using the recommended function, see I18n Issues for other reasons why Globalyzer is detecting the function.

Locale-Sensitive C/C++ String Operation Functions

 

Lingoport internationalization and localization services and software