Boost logo

Boost :

Subject: Re: [boost] [locale] Strange(?) result in example code
From: Artyom (artyomtnk_at_[hidden])
Date: 2011-04-16 09:31:43


> >
> > > 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, basically if you want to do it fully for standard library and boost:

std::locale::global(loc);
std::cout.imbue(loc);
std::cin.imbue(loc);
std::cerr.imbue(loc);
std::clog.imbue(loc);

std::wcout.imbue(loc);
std::wcin.imbue(loc);
std::wcerr.imbue(loc);
std::wclog.imbue(loc);

// this is for boost filesystem
boost::filesystem::path::imbue(loc);

>
> Paul

Artyom


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