Boost logo

Boost :

From: Martin Adrian (adrianm_at_[hidden])
Date: 2006-02-28 09:42:50


Yuval Ronen <ronen_yuval <at> yahoo.com> writes:
> After thinking about it some more, perhaps what I'm complaining about is
> something that is general in the locale/facet system. Maybe what's
> really bothering me is that once a certain setting is considered as
> "locale related", such as the decimal separator, it can only be
> configured using the locale/facet over-complicated way. But sometimes I
> don't want to use the "US", "German" or any other local setting for a
> decimal separator - I want to use *my* decimal separator. I souldn'd be
> forced to use a locale in such cases, IMO. IOW, I wish *all* settings
> would be configurable using manipulators (or an equivalent convenient
> way), and yes, that includes a decimal separator manipulator...

I use a set of facet helper classes.

ss.imbue(add_facet(locale(), new number_format<char>(":")));
ss << 1.23; // output "1:23"

ss.imbue(add_facet(locale::classic(),
                   new number_format<char>(':', '_', "43")));
ss << 12345678.9; // output "1_234_5678:9"

ss.imbue(add_facet(locale(), new stream_delimiter<char>(";\t")));
ss.str("123;String with spaces\t456");

int n1, n2;
string s1;
ss >> n1 >> s1 >> n2; // n1=123, n2=456, s1="String with spaces"


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