Internationalization and localization tools


Locale-Sensitive Windows C++ Comparison Methods

int Collate(LPCTSTR lpsz) const;

int CollateNoCase(LPCTSTR lpsz) const;

int Compare(LPCTSTR lpsz) const;

int CompareNoCase(LPCTSTR lpsz) const;

Internationalization (I18n) Method Overview

These methods perform string comparison/collation between the string associated with the class object and the string passed in as an argument. They return a negative value if the object's string is less than lpsz; a positive value if the object's string is greater than lpsz; and 0 if the strings are equal.

Collate performs a case-sensitive comparison of the strings; it is a wrapper method for the Generic C function, _tcscoll.

CollateNoCase performs a case-insensitive comparison of the strings; it is a wrapper method for the Generic C function, _tcsicoll.

Compare performs a case-sensitive comparison of the strings; it is a wrapper method for the Generic C function, _tcscmp.

CompareNoCase performs a case-insensitive comparison of the strings; it is a wrapper method for the Generic C function, _tcsicmp.

These methods are part of the CString class. For more information on these and other CString methods see the MSDN Library.

I18n Issues

These methods are all wrappers for their associated Generic C functions. In other words, the actual function that is called is dependent on the _MBCS and _UNICODE compiler flags. In an _MBCS compile, the methods will call the MBCS C functions; in a _UNICODE compile, the wide-character functions will be called.

Compare and CompareNoCase should only be used for equality comparisons since they will not correctly sort characters outside the ASCII range. See _mbscmp/wcscmp or _mbsicmp/wcsicmp for more information.

Collate and CollateNoCase correctly sort strings according to the currently set locale. Prior to calling one of these functions, ensure that the current locale is set properly by calling setlocale. See _mbscoll/wcscoll or _mbsicoll/_wcsicoll for more information.

For Windows MBCS support, ensure that the multibyte code page is set correctly. See _setmbcp for information on setting up the multibyte code page.

Locale-Sensitive Windows C++ Methods

 

Lingoport internationalization and localization services and software