共用方式為


locale::global

重設程式的預設地區設定。 這會影響 C 和 C++ 的全域地區設定。

static locale global(
    const locale& _Loc
);

參數

  • _Loc
    做為預設地區設定要使用的地區設定由程式。

傳回值

在預設地區設定之前的上一個地區設定重設。

備註

在程式啟動時,全域地區設定與傳統地區設定。 global() 函式會呼叫建立符合地區設定的 setlocale( LC_ALL, loc.name. c_str()) 會在標準 C 程式庫中。

範例

// locale_global.cpp
// compile by using: /EHsc
#include <locale>
#include <iostream>
#include <tchar.h>
using namespace std;

int main( )
{
   locale loc ( "German_germany" );
   locale loc1;
   cout << "The initial locale is: " << loc1.name( ) << endl;
   locale loc2 = locale::global ( loc );
   locale loc3;
   cout << "The current locale is: " << loc3.name( ) << endl;
   cout << "The previous locale was: " << loc2.name( ) << endl;
}
  

需求

標題: <地區設定>

命名空間: std

請參閱

參考

locale 類別