-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DoubleAttribute return integer on some PC #160
Comments
What happens if you printf("%f\n", child->DoubleAttribute("attr") )? Does that give you 0 as well? |
printf return: "0,000000" So, it's probably locale bug. |
The comma kinda gives it away, doesn't it? Have you tried using setlocale() to set the system locale and see if that fixes it? |
setlocale(LC_ALL, "en_US.UTF-8"); |
Closing - a strange behavior, and please feel free to continue the discussion, but it doesn't point to an issue with TinyXML-2. |
Lee, I beg to differ. It means that, just because Windows and MacOS always run C with a fixed locale setting, TinyXML shouldn't assume that it can use internationalized parsing calls for parsing floating point numbers that are always supposed to be written the English way. Is tinyxml2 supposed to be thread-safe? If not, I suppose you could just call setlocale() before parsing a float and afterwards restore the locale. Alternately, there's a Stackoverflow thread with other fixes here: http://stackoverflow.com/questions/1994658/locale-independent-strtod-implementation |
I see your point...re-read the thread. And re-opening. I have always avoided the local stuff in C because it isn't reliable. (Hello Irony! Good to see you.) We could get/set/restore the locale, but that potentially introduces a threading bug - although that's a total guess. Not clear to me what the thread model is from a quick scan of the docs. There's no real XML behavior here - it's the convenience methods that aren't working - but they should work reliably. |
Hi, We also experiencing issues with local switch between computer/languages. Would it be possible to fix that? |
At the first, here is simple code example:
On my work PC(Gentoo Linux x86_64) I get:
0.6 0.6
But on my old notebook(Ubuntu Linux x86_64) I get:
0 0.6
Actually, any float number returned as integer. And this bug reproduced not only on one PC. But I still did not see any dependency.
The text was updated successfully, but these errors were encountered: