Partager via


CStringT::Collate

Compares two strings using the generic-text function _tcscoll.

int Collate(
   PCXSTR psz
) const throw();

Parameters

  • psz
    The other string used for comparison.

Return Value

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

Remarks

The generic-text function _tcscoll, which is defined in TCHAR.H, maps to either strcoll, wcscoll, or _mbscoll, depending on the character set that is defined at compile time. Each function performs a case-sensitive comparison of the strings according to the code page currently in use. For more information, see strcoll, wcscoll, _mbscoll, _strcoll_l, _wcscoll_l, _mbscoll_l.

Example

// typedef CStringT<TCHAR, StrTraitATL<TCHAR, ChTraitsCRT<TCHAR>>> CAtlString;
_tsetlocale(LC_ALL, _T("german"));

CAtlString str1 = _T("strasse");
CAtlString str2 = _T("strae");

int n;

n = str1.Collate(str2);
ASSERT(n == 0);

// Comparison is a strict ASCII comparison with no language rules.
n = str1.Compare(str2);
ASSERT(n < 0);   

Requirements

Header: cstringt.h

See Also

Concepts

CStringT Class

CStringT Members