共用方式為


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 類別