J
jd
I have just spent the past week reading up on locales in books by Josuttis
and Stroustrup. As a simple test of locales, I prepared the following
source code below. The purpose is to convert the French decimal number
1.234,567 to the English equivalent of 1,234.567.
std::locale oFrenchLocale( "French_Canada.1252" );
std::string oS = "1.234,456";
std::istringstream oISS( oS );
std::locale oOldLocale = oISS.imbue( oFrenchLocale );
double dValue;
oISS >> dValue;
oISS.imbue( oOldLocale );
std::cout << "\n string=" << oS.c_str() << "\n dValue=" << dValue;
The output is:
string=1.234,456
dValue=1
I was expecting dValue to have a value of 1,234.567 but instead it only has
a value of 1. Would someone kindly provide me with the mistake I am making.
Thanks in advance.
Ian
and Stroustrup. As a simple test of locales, I prepared the following
source code below. The purpose is to convert the French decimal number
1.234,567 to the English equivalent of 1,234.567.
std::locale oFrenchLocale( "French_Canada.1252" );
std::string oS = "1.234,456";
std::istringstream oISS( oS );
std::locale oOldLocale = oISS.imbue( oFrenchLocale );
double dValue;
oISS >> dValue;
oISS.imbue( oOldLocale );
std::cout << "\n string=" << oS.c_str() << "\n dValue=" << dValue;
The output is:
string=1.234,456
dValue=1
I was expecting dValue to have a value of 1,234.567 but instead it only has
a value of 1. Would someone kindly provide me with the mistake I am making.
Thanks in advance.
Ian