Locale-Sensitive C/C++ Collation Function
int stricmp(const char* string1, const char* string2);
int _stricmp(const char* string1, const char* string2);
int strcmpi(const char* string1, const char* string2);
int _strcmpi(const char* string1, const char* string2);
int _mbsicmp(const unsigned char* string1, const unsigned char* string2);
int _wcsicmp(const wchar_t* string1, const wchar_t* string2);
int _tcsicmp(const _TXCHAR* string1, const _TXCHAR* string2);
Internationalization (I18n) Function Overview
The stricmp function compares two null-terminated strings, ignoring case. All uppercase characters are mapped to lowercase characters for comparison. It returns zero if the strings are equal, a negative number if string1 is less than string2 and a positive number if string1 is greater than string2 . If one string is a prefix of the other, the longer string is greater than the shorter string.
All except the stricmp function are supported only on Windows platforms.
_mbsicmp and _wcsicmp are multibyte and wide character versions of _stricmp . The arguments of _mbsicmp are multibyte-character strings; those of _wcsicmp are wide-character strings.
_tcsicmp is the Windows-only Generic version of the function; with the _MBCS or _UNICODE compiler flags determining its mapping to either _mbsicmp or _wcsicmp .
_strcmpi and strcmpi are provided for backward compatibility only and are identical to stricmp .
I18n Issues
Use the appropriate version of the function as required for internationalization support, noting the following:
The single-byte versions of the function, stricmp and _stricmp , should not be used for equality comparison, because they will only work with single-byte characters.
On Windows platforms, call _mbcsicmp or _wcsicmp . On ANSI UTF-8 platforms, convert the UTF-8 strings to wide character strings and then call wcscasecmp on the wide strings.
On ANSI UTF-16 platforms, call wcscasecmp .
In addition, these functions should not be used for character collation, i.e. alphabetization, because outside of the ASCII subset of characters, they will not sort according to the character set sort order rules of a specific locale.
Instead, call one of the collation functions listed below.
Ensure that the locale, which is used for case conversion, is set correctly using setlocale .
For Windows MBCS support, ensure that the multibyte code page is set correctly. See _setmbcp for information on setting up the multibyte code page.
Recommended Replacements*
For equality comparisons use
*If you're already using the recommended function, see I18n Issues for other reasons why Globalyzer is detecting the function.
For purposes of character collation, there are multibyte and wide functions for handling international sorting. These functions differ from the traditional stricmp in that they use locale-specific sorting rather than collating by a character's encoded value. The value assigned to LC_COLLATE within the machine's environment when the program runs dictates the locale-specific sorting rules drawn from by the collation functions.
For collation use
Collation
Functions
|