Boost logo

Boost :

Subject: Re: [boost] [locale] Strange(?) result in example code
From: Gevorg Voskanyan (v_gevorg_at_[hidden])
Date: 2011-04-16 06:43:00


Paul A. Bristow wrote:
> To: boost_at_[hidden]
> Sent: Sat, April 16, 2011 2:40:10 PM
> Subject: Re: [boost] [locale] Strange(?) result in example code
>
> > -----Original Message-----
> > From: boost-bounces_at_[hidden] [mailto:boost-bounces_at_[hidden]]
> > On Behalf Of Noah Roberts
> > Sent: Friday, April 15, 2011 8:43 PM
> > To: boost_at_[hidden]
> > Subject: Re: [boost] [locale] Strange(?) result in example code
> >
> > On 4/15/2011 12:38 PM, Artyom wrote:
> >
> > > 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'?

Yes.

> 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. See 27.4.2.3/4 of C++03.

HTH,
Gevorg


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk