[convert] coversion between strings with different locales

Hi, I wanted to see how we can convert a double from a locale to another locale? Should I write double d =convert<string>::from(convert<double>::from(str)(_locale=f))(_locale=t); or I need double d = convert<double>::from(str)(_locale=f); convert<string>::from(d)(_locale=d); Or it si a better way? Best, _____________________ Vicente Juan Botet Escribá

Some syntax errors string str_out =convert<string>::from(convert<double>::from(str)(_locale=f))(_locale=t); double d = convert<double>::from(str)(_locale=f); string str_out = convert<string>::from(d)(_locale=d); Thanks, Vicente ----- Original Message ----- From: "vicente.botet" <vicente.botet@wanadoo.fr> To: <boost@lists.boost.org> Sent: Thursday, July 09, 2009 9:11 AM Subject: [boost] [convert] coversion between strings with different locales Hi, I wanted to see how we can convert a double from a locale to another locale? Should I write double d =convert<string>::from(convert<double>::from(str)(_locale=f))(_locale=t); or I need double d = convert<double>::from(str)(_locale=f); convert<string>::from(d)(_locale=d); Or it si a better way? Best, _____________________ Vicente Juan Botet Escribá _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

From: "vicente.botet" <vicente.botet@wanadoo.fr> 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.

Hi, ----- Original Message ----- From: "Vladimir Batov" <batov@people.net.au> To: <boost@lists.boost.org> Sent: Thursday, July 09, 2009 10:13 AM Subject: Re: [boost] [convert] coversion between strings with differentlocales
From: "vicente.botet" <vicente.botet@wanadoo.fr> 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);
you mean string fr_double = convert<string>::from<***double***>( 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&);
There is something missing in this function. The intermediary class. Anyway I don't think we need a specific function for this specific case. I would prefer to qualify the string class be converted with formatting specifics. string fr_double = convert_to_using<fr_locale<string>, double>::from(en_locale(en_str)); which can be readen as convert from a string representing a double with the english locale to a string with a french locale. Best, Vicente
participants (2)
-
vicente.botet
-
Vladimir Batov