locale::global
Resets the default local for the program. This affects the global locale for both C and C++.
static locale global(
const locale& _Loc
);
Parameters
- _Loc
The locale to be used as the default locale by the program.
Return Value
The previous locale before the default locale was reset.
Remarks
At program startup, the global locale is the same as the classic locale. The global() function calls setlocale( LC_ALL, loc.name. c_str()) to establish a matching locale in the Standard C library.
Example
// locale_global.cpp
// compile with: /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;
}
The initial locale is: C The current locale is: German_Germany.1252 The previous locale was: C
Requirements
Header: <locale>
Namespace: std