collate::transform

转换从区域设置的字符序列。能在与相同区域设置转换类似的其他字符序列的字典来比较的字符串。

string_type transform( 
   const CharType* _First, 
   const CharType* _Last 
) const;

参数

  • _First
    到第一个字符的指针将的转换序列。

  • _Last
    对最后一个字符的指针将的转换序列。

返回值

包含转换的字符组成的字符串。

备注

成员函数返回 do_transform(_First,_Last)。

示例

// 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;
}
  

要求

页眉: <区域设置>

命名空间: std

请参见

参考

collate 类