Internationalization and localization tools


Locale-Sensitive C/C++ String Operation Function

char *strpbrk(const char *string, const char *strCharSet);

wchar_t *wcspbrk(const wchar_t *string, const wchar_t *strCharSet);

unsigned char *_mbspbrk(const unsigned char*string, const unsigned char *strCharSet);

_TXCHAR *_tcspbrk(const _TXCHAR *string, const _TXCHAR *strCharSet);

Internationalization (I18n) Function Overview

The strpbrk function returns a pointer to the first occurrence in string of a character in strCharSet, or NULL if the two string arguments have no characters in common.

wcspbrk is the wide character equivalent; its parameters and return are wide-character strings.

_mbspbrk is supported on Windows platforms only and is the multibyte equivalent; its parameters and return are multibyte strings.

_tcspbrk is the Windows-only Generic version of the function; with the _MBCS or _UNICODE compiler flags determining its mapping to either _mbspbrk or wcspbrk.

I18n Issues

The strpbrk function does not work if strCharSet contains multibyte UTF-8 characters. (In a string using a multibyte UTF-8 character encoding, characters consisting of more than one byte are not treated by strpbrk as an entity, each byte is treated separately.)

If strCharSet may possibly contain multibyte UTF-8 characters, the parameters (string and strCharSet) will have to be converted to wide characters (wchar_t) and then use the wide function wcspbrk. Similarly, the return value will then need to be converted from wide characters back to UTF-8 characters.

For Windows MBCS support, ensure that the multibyte code page is set properly, as _mbspbrk depends on it. By default, the multibyte code page is set to the system-default ANSI code page obtained from the operating system at program startup. Use _getmbcp and _setmbcp to query or change the current multibyte code page, respectively.

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