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