2014-05-13 11:58 GMT+02:00 David Krauss <
pot...@gmail.com>:
> On 2014-05-13, at 1:35 PM, Daniel Krügler <
daniel....@gmail.com> wrote:
> 2014-05-13 2:01 GMT+02:00 David Krauss <
pot...@gmail.com>:
> As someone recently noted here, to_string doesn't respect localization. It's
> better suited to serialization than user or OS interfaces.
>
> Unfortunately to_string still provides locale-dependency, albeit not
> to grouping symbols, but is not guaranteed to be "pure". It still is
> affected by locale effects that influence the decimal separator, for
> example.
>
> I've never used a compliant locales implementation (my OS of choice, Mac, is
> barely functional), but my impression of the spec is that to_string depends
> on the C library locale as set by setlocale, which is supposed to be
> independent of the C++ standard library (but isn't, at least on my OS, where
> the C library is the *only* way to set the C++ locale).
It is exactly the dependency on std::setlocale() I was referring to.
It is part of the C++ Standard library by inclusion and whether this
is a C dependency or a C++ dependency, is irrelevant for me. And any
(named) changes to the global std::local can also impact the
std::sprintf behaviour (22.3.1.5 [locale.statics]) p2:
"Effects: Causes future calls to the constructor locale() to return a
copy of the argument. If the
argument has a name, does
std::setlocale(LC_ALL,
loc.name().c_str());
otherwise, the effect on the C locale, if any, is implementation-defined."
- Daniel