Locale-Sensitive C/C++ String Operation Function
size_t strspn(const char *string, const char *strCharSet);
size_t wcsspn(const wchar_t *string, const wchar_t *strCharSet);
size_t _mbsspn(const unsigned char *string, const unsigned char *strCharSet);
size_t _tcsspn(const _TXCHAR *string, const _TXCHAR *strCharSet);
Internationalization (I18n) Function Overview
The strspn function returns the index of the first character in string
that does not belong to the set of characters in strCharSet . The search
does not include terminating null characters.
wcsspn is the wide character equivalent; its parameters are wide-character strings and it returns a wide-character index value.
_mbsspn is supported on Windows platforms only and is the multibyte equivalent; its parameters are multibyte strings and it returns a byte index.
_tcsspn is the Windows-only Generic version of the function; with the
_MBCS or _UNICODE compiler flags determining its mapping to either
_mbsspn or wcsspn .
I18n Issues
The strspn 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 strspn 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 wcsspn . Similarly, the return value will then need to be converted from wide characters back to UTF-8 characters.
For Windows MBCS platforms, ensure that the multibyte code page is set properly, as _mbsspn 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
|