Language localization with streams under C++

Heilmann, Thomas (GE51) thomas.heilmann@honeywell.com
Mon Jul 21 10:40:00 GMT 2003


Hello,

may be you can help me with my problem about language localization.

As I read in the documentation, for example "setlocale( LC_ALL, "German" );"
is the common way to set the language localization. But this will be valid
for
the whole program and it is not that what I want and need.

While programming with C++, there's the possibility to create a "locale"
object
and imbue a stream with it. Then this language localization is only valid
for
this stream and its life cycle. That is what I want and need.

Here a small example:
   std::ofstream OutFile;
   std::locale Local_German( "German" );
   OutFile.imbue( Local_German );

My problem is now, that this code is compilable, but while the program is
running
and would create this object 'Local_German', it crashes.
I checked this with several locale strings like "C", "", "English" and some
more.
With the first two, the locale object is created well and the program is
running well.
But with any other local string it crashes.

What's wrong with this ?
Is there anything missing on my SuSE 8.1 with gcc 3.2 system ?

Any comment helping me to solve that problem is welcomed !

Best regards

                  Thomas Heilmann



More information about the Gcc-help mailing list