Subject: Re: [boost] [locale] Strange(?) result in example code
From: Paul A. Bristow (pbristow_at_[hidden])
Date: 2011-04-18 07:30:13
> -----Original Message-----
> From: boost-bounces_at_[hidden] [mailto:boost-bounces_at_[hidden]]
> On Behalf Of Artyom
> Sent: Saturday, April 16, 2011 2:32 PM
> To: boost_at_[hidden]
> Subject: Re: [boost] [locale] Strange(?) result in example code
> > >
> > > > std::cout.imbue(std::locale()); // Now global locale imbued to
> > > > stream as
> > well.
> > >
> > > LOL, DUH! OK. Thanks.
> > Well join the club - I've fallen into this pit recently :-(
> > Am I correct in thinking that the reason is that std::cout is
> > constructed
> > *before* the new locale is 'globalled'?
> > And so std::cerr needs imbuing too but that fstream and stringstreams
> > constructed after the std::locale::global("en_US.UTF-8") statement
> > will get the new locale?
> Yes, basically if you want to do it fully for standard library and boost:
> // this is for boost filesystem
Thanks for this confirmation.
This seems such an obviously attractive pit, I am sure Noah and I won't be
the last to fall in it ;-)
I think Boost.Locale docs would be a good place to remind users of locale of
its existence, including a reference to 220.127.116.11/4 of C++03.
Would you like to add it as a [warning ....] while you are crossing the 't's
and dotting the 'i's ?
--- Paul A. Bristow, Prizet Farmhouse, Kendal LA8 8AB UK +44 1539 561830 07714330204 pbristow_at_[hidden]
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk