K
kenwilkinson
I use Dinkumware's STL with Borland C++ Builder 2006 (part of BDS
2006) to convert from a character array to a double in a Windows
application. This approach works well for English, but fails for
French as "0,1" (note the comma) is not interpreted as a decimal
point. What can I do to get setlocale() or Window's French regional
setting to work? Thanks. -Ken
#include <strstream>
double d;
setlocale(LC_ALL, "C");
SMove( d, "0.1"); // decimal point is a period. result: d = 0.1
setlocale(LC_ALL, "french");
SMove( d, "0,1"); // decimal point is a comma. result: d = 0
void SMove( double& dVal, char *sStr, int nLen )
{
istrstream s( sStr, nLen );
s >> dVal;
}
2006) to convert from a character array to a double in a Windows
application. This approach works well for English, but fails for
French as "0,1" (note the comma) is not interpreted as a decimal
point. What can I do to get setlocale() or Window's French regional
setting to work? Thanks. -Ken
#include <strstream>
double d;
setlocale(LC_ALL, "C");
SMove( d, "0.1"); // decimal point is a period. result: d = 0.1
setlocale(LC_ALL, "french");
SMove( d, "0,1"); // decimal point is a comma. result: d = 0
void SMove( double& dVal, char *sStr, int nLen )
{
istrstream s( sStr, nLen );
s >> dVal;
}