This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: std::locale does not work here
- From: Nathan Myers <ncm-nospam at cantrip dot org>
- To: libstdc++ at gcc dot gnu dot org
- Date: Mon, 21 Jun 2004 19:01:59 -0700
- Subject: Re: std::locale does not work here
- References: <40D77E45.2070002@stud.fh-dortmund.de>
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