std::locale does not work here
Patrick Gräbel
pgraebel@stud.fh-dortmund.de
Tue Jun 22 02:53:00 GMT 2004
I know, that there are different supported locale strings on Windows
(e.g. "eng"), Linux/POSIX (e.g. "en_US") and so on.
Is there a way to test the locale string support? Stroustrup says in his
C++ book, that there is a "runtime_error" exception thrown by the
std::locale's constructor, if the locale string argument is not
supported by the executing OS. But Cygwin & Debian/stable's gnu stdc++
libs do not react on unsupported locale strings...
Is there any gnu stdc++ lib port out there, that supports more than "C"?
-Patrick
Nathan Myers wrote:
> On Tue, Jun 22, 2004 at 02:33:09AM +0200, Patrick Gr?bel wrote:
>
>>I am using Cygwin (g++-3.3.1) and Debian/stable (g++-3.0.1). The
>>following call will not throw an "runtime_error" that is described in
>>Stroustrup's C++ bible:
>>
>>std::locale loc("$$???XXXYYY????!!!");
>>
>>The constructor even accepts locale strings, that do not make sense.
>>Also the following code will _not_ produce a ',' instead of a '.':
>>
>>std::locale loc("de_DE");
>>double d = 1.76;
>>std::cout.imbue(loc);
>>std::cout << d << std::endl;
>>
>>That's weird. Is g++'s stdc++ lib incompatible to the standard?
>
>
> The standard says very little about what makes a useful locale name.
> If the implementation claims POSIX compatibility, you might reasonably
> expect POSIX locale names to mean something. It's all up to the
> documentation for your implementation, which is likely to defer to the
> OS. All you're guaranteed is that "C" or "POSIX" will do something
> not too unreasonable -- in the opinion of the implementer. It's
> called "quality of implementation", and lousy implementations are
> allowed, and hoped to be out-competed by good ones. Often, there's
> not much an implementation can do if the OS doesn't help.
>
> The implication is just that locale name strings should never be
> compiled in to a portable program. Get it from a config file,
> environment variable, or "resource".
>
> (Is this an FAQ?)
>
> Nathan Myers
> ncm-nospam@cantrip.org
>
More information about the Libstdc++
mailing list