Carsten A. Arnholm
2014-09-02 22:53:39 UTC
This is rather frustrating....
I am Kubuntu 14.04 and I am in Norway. The KDE locale has been set to
use only decimal point ("full stop") instead of comma which some "wise
men" have decided should be the standard in this country.
Now I am trying to write a small console program writing an XML file
using wx3.0.1, this file shall not use anything else but the "C" locale,
as the files will be copied around the world, and it contains numerical
values.
double temp = 29.862;
wxString string_temp = wxString::Format("%f",temp)
No matter what I try, I get "29,862000" as value of the string_temp, and
it breaks my application completely. I also don't understand how this
can happen given both the settings of the program and my system settings.
I used to have this problem with wx2.8 a couple of years ago, and the
work-around then was to include the following in the main program
wxLocale locale(wxLANGUAGE_ENGLISH);
Note I really don't want an english locale, I want the "C" locale. In
fact, all I want is to be able to read and write decimal numbers using
full stop as the decimal separator. Now the work around does not work
anymore. What am I doing wrong? this should really not be so hard.
Out of desperation I also tried
std::setlocale(LC_NUMERIC,"C");
But it has no effect in wxWidgets
.
Please can you explain what is going on, and how to read and write
numbers using "C" locale specification?
----
Hmmm I did a bit of research, here is a snippet from my main program
int main(int argc, char **argv)
{
// std::setlocale(LC_NUMERIC,"C");
// initialise wxWidgets library
wxInitializer initializer(argc,argv);
wxLocale locale(wxLANGUAGE_ENGLISH);
double ttemp = 29.862;
char buf[80];
// parse command lin
wxCmdLineParser parser(cmdLineDesc);
parser.SetSwitchChars(wxT("-"));
sprintf(buf,"one %f",ttemp);
cout << buf << endl;
parser.SetCmdLine(argc,argv);
sprintf(buf,"two %f",ttemp);
cout << buf << endl;
if(parser.Parse() != 0) {
// command line parameter error
return 1;
}
// etc...
]
The output from this test is
one 29.862000
two 29,862000
I find it rather problematic that a call to parser.SetCmdLine(argc,argv);
changes my program locale silently?
Carsten Arnholm
I am Kubuntu 14.04 and I am in Norway. The KDE locale has been set to
use only decimal point ("full stop") instead of comma which some "wise
men" have decided should be the standard in this country.
Now I am trying to write a small console program writing an XML file
using wx3.0.1, this file shall not use anything else but the "C" locale,
as the files will be copied around the world, and it contains numerical
values.
double temp = 29.862;
wxString string_temp = wxString::Format("%f",temp)
No matter what I try, I get "29,862000" as value of the string_temp, and
it breaks my application completely. I also don't understand how this
can happen given both the settings of the program and my system settings.
I used to have this problem with wx2.8 a couple of years ago, and the
work-around then was to include the following in the main program
wxLocale locale(wxLANGUAGE_ENGLISH);
Note I really don't want an english locale, I want the "C" locale. In
fact, all I want is to be able to read and write decimal numbers using
full stop as the decimal separator. Now the work around does not work
anymore. What am I doing wrong? this should really not be so hard.
Out of desperation I also tried
std::setlocale(LC_NUMERIC,"C");
But it has no effect in wxWidgets
.
Please can you explain what is going on, and how to read and write
numbers using "C" locale specification?
----
Hmmm I did a bit of research, here is a snippet from my main program
int main(int argc, char **argv)
{
// std::setlocale(LC_NUMERIC,"C");
// initialise wxWidgets library
wxInitializer initializer(argc,argv);
wxLocale locale(wxLANGUAGE_ENGLISH);
double ttemp = 29.862;
char buf[80];
// parse command lin
wxCmdLineParser parser(cmdLineDesc);
parser.SetSwitchChars(wxT("-"));
sprintf(buf,"one %f",ttemp);
cout << buf << endl;
parser.SetCmdLine(argc,argv);
sprintf(buf,"two %f",ttemp);
cout << buf << endl;
if(parser.Parse() != 0) {
// command line parameter error
return 1;
}
// etc...
]
The output from this test is
one 29.862000
two 29,862000
I find it rather problematic that a call to parser.SetCmdLine(argc,argv);
changes my program locale silently?
Carsten Arnholm
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users