This documentation is archived and is not being maintained.


Compares two strings using the generic-text function _tcscoll.

int CollateNoCase(
   PCXSTR psz
) const throw();


The other string used for comparison.

Return Value

Zero if the strings are identical (ignoring case), < 0 if this CStringT object is less than psz (ignoring case), or > 0 if this CStringT object is greater than psz (ignoring case).


The generic-text function _tcscoll, which is defined in TCHAR.H, maps to either stricoll, wcsicoll, or _mbsicoll depending on the character set that is defined at compile time. Each of these functions performs a case-insensitive comparison of the strings, according to the code page currently in use. For more information, see strcoll, wcscoll, _mbscoll in the Run-Time Library Reference.


The following example demonstrates the use of CStringT::CollateNoCase.

//typedef CStringT< TCHAR, StrTraitATL< TCHAR > > CAtlString;

CAtlString str1 = _T("Co-Op");
CAtlString str2 = _T("con");

int n;

// Collation uses language rules, such as ignoring dashes
// NoCase version ignores case
n = str1.CollateNoCase(str2);
_ASSERT(n > 0);

// Comparison is a strict ASCII comparison with no language rules
// but still ignores case in NoCase version
n = str1.CompareNoCase(str2);
_ASSERT(n < 0);

See Also

CStringT Overview | Class Members