Boost logo

Boost :

Subject: Re: [boost] [locale] Review
From: Noah Roberts (roberts.noah_at_[hidden])
Date: 2011-04-18 12:28:01


On 2011-04-16 01:45, Artyom wrote:
>
>
>
>
> ----- Original Message ----
>> From: Noah Roberts<roberts.noah_at_[hidden]>
>>
>> Actually, I ran into what I would call a bug.
>>
>> #include<boost/locale.hpp>
>> #include<boost/lexical_cast.hpp>
>>
>> #include<iostream>
>>
>> using namespace boost::locale;
>>
>> int main()
>> {
>> generator gen;
>>
>> std::locale::global(gen("fr_CA.UTF-8"));
>> //std::locale::global(std::locale(""));
>>
>> std::string dbl = boost::lexical_cast<std::string>(3.14);
>> std::cout<< dbl<< std::endl;
>>
>> std::cin.get();
>> }
>>
>> My language settings currently use ',' as decimal separator as do the settings
>> for
>> the french (Canada) language settings.
>>
>> The commented out version outputs "3,14000000001".
>> This is what I would expect to happen. The boost::locale version
>> outputs "3.14000000001".
>>
>> It looks to me like the punctuation stuff isn't being set up correctly.
>> The as::number thing doesn't do anything either. Only locale::format catches
>> on
>> and does it right.

> It is by design.

Then what is the correct work-around to get past this "design"? Some
people, like me, make frequent use of boost::format (which your version
cannot replace because it does not implement 'g' formatting), and other
functions that output in characters specific to the locale and know
nothing about as::anything.

This is a problem. The library, perhaps rightly, doesn't follow
standard conventions but it also doesn't replicate those functions which
do. Can I use only your translation functionality without imbuing the
streams with your locale? Something tells me that won't work out quite
right.

If this design is going to stick, then there certainly needs to be a
documented workaround so that those of us who need the behavior can get it.


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