Boost logo

Boost :

Subject: Re: [boost] [boost[program options] locale support
From: Vladimir Prus (vladimir_at_[hidden])
Date: 2010-06-21 07:34:02

Christoph Heindl wrote:

> hi,
> from the documentation [1] : "[...] the library uses the
> codecvt<wchar_t, char> locale facet from the global locale."
> The quote is taken from the unicode-documentation part. May i ask why
> the locale is taken from the global locale, instead of the locale
> assigned to the stream?

What do you mean by "the stream"?

> What I'd like to do is (currently yields a logic_error)
> // assume stream contains "a = 1,2"
> // ...
> std::locale loc("German_Germany");
> stream.imbue(loc);
> po::parse_config_file(stream, opts, false);

Ah, that's what you mean. The problem is that command-line parsing
does not have any associated locale other than the global one, and
it would be somewhat awkward to remember a locale associated with
source config file.

> instead i have to
> std::locale loc("German_Germany");
> std::locale::global(loc);
> po::parse_config_file(stream, opts, false);
> to parse the config file correctly.

Is it common to use different locales for different files?

- Volodya

Boost list run by bdawes at, gregod at, cpdaniel at, john at