Horde3D

Next-Generation Graphics Engine
It is currently 22.11.2024, 06:46

All times are UTC + 1 hour




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Locale problems
PostPosted: 04.11.2008, 22:19 
Offline

Joined: 03.07.2008, 01:23
Posts: 50
Horde3D loads files apparently trusting that e.g. atof interprets strings such as "0.25" correctly as the decimal number one fourth (instead of interpreting it as "0" which happens on locales using a comma). Another locale makes reading pipeline configuration files fail. Unless, of course, I set the locale myself before calling any Horde3D functions.

I think Horde should set the locale, though I admit this is totally boring.

Is the convention to write your Horde XML files in your own locale? I think this is against the spirit of sharing. Actually, I think it's pretty awkward that atof should fail like that anyway... :roll:


Top
 Profile  
Reply with quote  
 Post subject: Re: Locale problems
PostPosted: 04.11.2008, 23:21 
Offline

Joined: 22.11.2007, 17:05
Posts: 707
Location: Boston, MA
cantele wrote:
I think Horde should set the locale.
Is this a good idea? We would be forcing everybody to use the same locale.
Quote:
Is the convention to write your Horde XML files in your own locale?
Generally one writes all files in one's own locale.
Quote:
I think this is against the spirit of sharing. Actually, I think it's pretty awkward that atof should fail like that anyway... :roll:
If everything works as it should, then whatever locale you have defined for your operating system should be used by default for the program. Unfortunately, there is no way to detect if a number is in another locale (unless we explicitly embed that information in the XML).

We could setlocale("C"); at the beginning of Horde, which would read and write all files in the global C locale, but unfortunately this may conflict with the user's choice of locale, or with other libraries.

_________________
Tristam MacDonald - [swiftcoding]


Top
 Profile  
Reply with quote  
 Post subject: Re: Locale problems
PostPosted: 04.11.2008, 23:29 
Offline

Joined: 19.03.2008, 01:22
Posts: 79
Or we could use a custom locale-independant replacement for the offending functions. This way XML processing would work as intended and everything else would be unaffected.


Top
 Profile  
Reply with quote  
 Post subject: Re: Locale problems
PostPosted: 05.11.2008, 07:52 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
Although in Germany floating point numbers are normally written with commas, I'm accustomed to use points when writing floating point numbers in XML files because this is the default behaviour of atof when parsing strings if the locale is not set specifically. If we should change something concerning the locale, I would prefer writing custom parsing methods that would use always points, since I agree with cantele that considering the open source spirit it should be possible to share contents across cultures.

But personally I would prefer to not change anything. If someone sets the locale externally to a specific setting, he/she has to care about the format of it's XML files, too.


Top
 Profile  
Reply with quote  
 Post subject: Re: Locale problems
PostPosted: 09.11.2008, 12:34 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
The separator for floats should always be the dot. Commas are reserved for other things like lists or tuples. In the future, it could make sense to have our own atof function since it can be many times faster than the standard one.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group