Internationalization and localization tools


Locale-Sensitive Windows C++ Function

int lstrcmpi(LPCTSTR lpString1, LPCTSTR lpString2);

int lstrcmpiA(LPCSTR lpString1, LPCSTR lpString2);

int lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2);

Internationalization (I18n) Function Overview

The lstrcmpi function performs a case-sensitive compare of two null-terminated strings. It returns zero if the strings are equal, a negative number if lpString1 is less than lpString2 and a positive number if lpString1 is greater than lpString2. If one string is a prefix of the other, the longer string is greater than the shorter string.

lstrcmpiA is the narrow version of the function; its arguments and return are single-byte or multibyte strings.

lstrcmpiW is the wide version of the function; its arguments and return are wide-character strings.

See the MSDN Library for more information.

I18n Issues

lstrcmpi should not be used in an internationalized application because its comparison relies on a language setting that may differ from the program's locale. Instead, use CompareString, which allows a locale to be passed in as an argument.

Recommended Replacements*

Use the Generic version of the function rather than the narrow or wide versions, and let the Windows #define UNICODE switch determine which version of the function will be called. Using the Generic version facilitates switching between an MBCS and UTF-16 Unicode application.

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

Locale-Sensitive Windows C++ Functions

 

Lingoport internationalization and localization services and software