Boost logo

Boost :

Subject: Re: [boost] [locale] Review
From: Noah Roberts (roberts.noah_at_[hidden])
Date: 2011-04-15 21:04:55

On 4/15/2011 3:53 PM, Noah Roberts wrote:
> - What is your evaluation of the design?
> Functions. Seems straight forward to use.
> - What is your evaluation of the implementation?
> What I used worked. I did not look over the source.

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::string dbl = boost::lexical_cast<std::string>(3.14);
   std::cout << dbl << std::endl;


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.

I managed to get it going by hacking around a bit. Not sure if what I'm
doing is actually close to anything that might be what it should be...

std::locale loc0(gen(""));
std::locale loc1("");
std::locale::global(std::locale(loc0, loc1, std::locale::all));

I'd expect that the delimiters and such would be set up the same in both
cases and this merge attempt of mine shouldn't be necessary.

Boost list run by bdawes at, gregod at, cpdaniel at, john at