collate::transform
Converts a character sequence from a locale to a string that may be used in lexicographical comparisons with other character sequences similarly converted from the same locale.
string_type transform(
const CharType* _First,
const CharType* _Last
) const;
Parameters
_First
A pointer to the first character in the sequence to be converted._Last
A pointer to the last character in the sequence to be converted.
Return Value
A string that contains the transformed character sequence.
Remarks
The member function returns do_transform(_First, _Last).
Example
// collate_transform.cpp
// compile with: /EHsc
#include <locale>
#include <iostream>
#include <tchar.h>
using namespace std;
int main( )
{
locale loc ( "German_Germany" );
_TCHAR* s1 = _T("\x00dfzz abc.");
// \x00df is the German sharp-s (looks like beta),
// it comes before z in the alphabet
_TCHAR* s2 = _T("zzz abc.");
collate<_TCHAR>::string_type r1; // OK for typedef?
r1 = use_facet< collate<_TCHAR> > ( loc ).
transform (s1, &s1[_tcslen( s1 )-1 ]);
cout << r1 << endl;
basic_string<_TCHAR> r2 = use_facet< collate<_TCHAR> > ( loc ).
transform (s2, &s2[_tcslen( s2 )-1 ]);
cout << r2 << endl;
int result1 = use_facet<collate<_TCHAR> > ( loc ).compare
(s1, &s1[_tcslen( s1 )-1 ], s2, &s2[_tcslen( s2 )-1 ] );
cout << _tcscmp(r1.c_str( ),r2.c_str( )) << result1
<< _tcscmp(s1,s2) <<endl;
}
???????? ? ???? ??????? ? ???? -1-11
Requirements
Header: <locale>
Namespace: std