Hxuejie / cocos2d-windows-particle-editor

Automatically exported from code.google.com/p/cocos2d-windows-particle-editor
0 stars 0 forks source link

Wrong format when saving XML depending on system Culture [with fix] #1

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
When you save an XML file, you do not use InvariantCulture. Therefore, on my 
computer (French), float number are exported with commas instead of dots (0,25 
instead of 0.25). This then creates problems when reading the files. You need 
to change the following line in the WriteFloat method:
writer.WriteElementString( "real", val.ToString() ); 
to
writer.WriteElementString( "real", val.ToString( CultureInfo.InvariantCulture ) 
);

You also need to change when reading the number in ReadFloat:
return float.Parse(dict[name] );
to
return float.Parse(dict[name], CultureInfo.InvariantCulture );

Hope this helps,
Thanks!

Francois.

Original issue reported on code.google.com by guibert....@gmail.com on 28 Nov 2011 at 9:36