重置程序的默认区域设置。这会影响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;
}
要求
标头: <locale>
命名空间: std