« Return to Thread: [convert] coversion between strings with different locales

Re: [convert] coversion between strings with different locales

by Vladimir Batov :: Rate this Message:

Reply to Author | View in Thread

> From: "vicente.botet" <vicente.botet@...>
> I wanted to see how we can convert a double from a locale to another
> locale?
> ...

OTOH, I'd say

string en_double = ...;
double d = convert<double>::from(en_str)(locale_=en_locale);
string fr_double = convert<string>::from(d)(locale_=fr_locale);

If you want to stitch it all together, it becomes a scary

string fr_double =
    convert<string>::from(
        convert<double>::from(en_str)(locale_=en_locale).value()
    )(locale_=fr_locale);

or as scary

string fr_double =
    convert<string>::from<string>(
        convert<double>::from(en_str)(locale_=en_locale)
    )(locale_=fr_locale);

If needed, I'd probably wrap it up in a function like

template<class T>
T convert(T const&, locale const&, locale const&);

V.

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

 « Return to Thread: [convert] coversion between strings with different locales