Floating point string format

A place for Ogre users to discuss non-Ogre subjects with friends from the community.
Crashy
Google Summer of Code Student
Google Summer of Code Student
Posts: 1005
Joined: Wed Jan 08, 2003 9:15 pm
Location: Lyon, France
x 49

Floating point string format

Post by Crashy »

Hello everybody.

I've got a nice issue right here. When I launch my game with it's own executable, everything runs fine.
If I run it within a wxwidget application, material parameters are wrong.

The cause? The floating point string format, which is "," in french system, and "." in us-en systems. So for example, sccanf will return either 0.05 or 0 when parsing this string
"param_named_auto psTime time 0.05", depending on which application I execute, the game or my wxwidget tool.

Of course I don't want to have multiple version of my material files, so I wonder if there is a way to force, at application startup, the format of the floating point in strings?

I also don't want to force users to change their system settings before running application.

Thanks.
Follow la Moustache on Twitter or on Facebook
Image
User avatar
lingfors
Hobgoblin
Posts: 525
Joined: Mon Apr 02, 2007 12:18 am
Location: Sweden
x 79

Re: Floating point string format

Post by lingfors »

http://msdn.microsoft.com/en-us/library/x99tb11d.aspx

If you're not running on Windows, I'm sure there's something similar.
Crashy
Google Summer of Code Student
Google Summer of Code Student
Posts: 1005
Joined: Wed Jan 08, 2003 9:15 pm
Location: Lyon, France
x 49

Re: Floating point string format

Post by Crashy »

Thank you, I'll try it out.

Edit: it works, thanks.
Follow la Moustache on Twitter or on Facebook
Image
User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
x 56

Re: Floating point string format

Post by Klaim »

There are cross-platform ways to make it work : http://www.cplusplus.com/reference/std/locale/

Also, maybe read this tutorial from Boost.Locale that explain why it's flawed : http://www.boost.org/doc/libs/1_48_0/li ... cales.html