Boost logo

Boost :

Subject: Re: [boost] [locale] Review
From: Artyom (artyomtnk_at_[hidden])
Date: 2011-04-18 11:39:28


> From: Gevorg Voskanyan <v_gevorg_at_[hidden]>
> To: boost_at_[hidden]
> Sent: Mon, April 18, 2011 4:06:59 PM
> Subject: Re: [boost] [locale] Review
>
> Artyom wrote:
> > If so please implement following in C correctly:
> >
> >
> > void delete_values_above_x(double x)
> > {
> > char statement[256];
> > snprintf(statement,sizeof(statement),"DELETE FROM sometable WHERE x >
> >%f",x);
> > mysql_query(connection,statement)
> > }
> >
> > When in current locale the decimal point is "," and x=3.14...
> >
> > You can't do it in reasonable simple way in C.
> > It is design issue of standard C and C++ library.
> >
> > Artyom
>
> While I agree about the standard C library, what issue does C++ standard
>library
>
> have here?
> You can just imbue std::locale::classic() and you are good to go. Am I missing
>
> something?
>

Calling std::locale::global(some_locale)
calls C function

   setlocale(LC_ALL,some_locale.name());

So even if you can fix C++ code you can't do it
for C libraries you may use.

Also 99.9% of C++ developers unaware of this issue and
almost nobody imbues std::locale::classic() because
they just not aware of the problem.

Artyom


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