locale::combine
要插入指定之地區設定的 Facet 至目標地區設定。
template<class Facet>
locale combine(
const locale& _Loc
) const;
參數
- _Loc
包含 Facet 的地區設定會插入目標地區設定。
傳回值
成員函式傳回取代或加入 Facet *thisFacet 在 _Loc清單的地區設定物件。
範例
// locale_combine.cpp
// compile with: /EHsc
#include <locale>
#include <iostream>
#include <tchar.h>
using namespace std;
int main() {
locale loc ( "German_germany" );
_TCHAR * s1 = _T("Das ist wei\x00dfzz."); // \x00df is the German sharp-s; it comes before z in the German alphabet
_TCHAR * s2 = _T("Das ist weizzz.");
int result1 = use_facet<collate<_TCHAR> > ( loc ).
compare (s1, &s1[_tcslen( s1 )-1 ], s2, &s2[_tcslen( s2 )-1 ] );
cout << isalpha (_T ( '\x00df' ), loc ) << result1 << endl;
locale loc2 ( "C" );
int result2 = use_facet<collate<_TCHAR> > ( loc2 ).
compare (s1, &s1[_tcslen( s1 )-1 ], s2, &s2[_tcslen( s2 )-1 ] );
cout << isalpha (_T ( '\x00df' ), loc2 ) << result2 << endl;
locale loc3 = loc2.combine<collate<_TCHAR> > (loc);
int result3 = use_facet<collate<_TCHAR> > ( loc3 ).
compare (s1, &s1[_tcslen( s1 )-1 ], s2, &s2[_tcslen( s2 )-1 ] );
cout << isalpha (_T ( '\x00df' ), loc3 ) << result3 << endl;
}
範例輸出
1-1
01
0-1
需求
標題: <地區設定>
命名空間: std