I crawled the web a lot and got not, what I searched for even not in SO. So I consider this a new question: How to reset the locale settings to a state when the program is starting (e.g. first after main()) ?
int
main( int argc, char **argv )
{
// this is start output I like to have finally again
std::cout << 24500 << " (start)\n";
// several modifications ... [e.g. arbitrary source code that cannot be changed]
std::setlocale( LC_ALL, "" );
std::cout << 24500 << " (stage1)\n";
std::locale::global( std::locale( "" ) );
std::cout << 24500 << " (stage2)\n";
std::cout.imbue( std::locale() );
std::cout << 24500 << " (stage3)\n";
std::wcerr.imbue( std::locale() );
std::cout << 24500 << " (stage4)\n";
// end ... here goes the code to reset to the entry-behaviour (but won't work so far)
std::setlocale( LC_ALL, "C" );
std::locale::global( std::locale() );
std::cout << 24500 << " (end)\n";
return 0;
}
Output:
24500 (start)
24500 (stage1)
24500 (stage2)
24.500 (stage3)
24.500 (stage4)
24.500 (end)
The line with the "(end)" should show the same number formatting as "(start)" ...
Does anyone know how (in a general! portable?) way ?