teolog's picture

Globalization has you

Project:Meshomatic
Version:0.2.1
Component:Code
Category:bug report
Priority:critical
Assigned:Unassigned
Status:fixed
Description

ObjLoader not working on non english system.
float x = float.Parse(parameters[1]) failed, on some regional settings float format "0,xxxx", but not "0.xxxx".
Needs to using
CultureInfo intern=new CultureInfo("en-US", false);
NumberFormatInfo nfi =intern.NumberFormat;
float x = float.Parse(parameters[1],nfi);


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

#1

IIRC, the suggested solution is to use CultureInfo.InvariantCulture when saving/loading files to/from disk.

c2woody's picture

#2

I can only second The Fiddler's suggestion, when dealing with a defined floating string format use something like

float myvalue = 0.0f;
if (Single.TryParse(mystring, NumberStyles.Float, CultureInfo.InvariantCulture, out myvalue)) {
  // use parsed value here...
}
Icefox's picture

#3

Quite correct. I will fix this when/if I ever get back around to this project.

Icefox's picture

#4

Status:open» fixed

Fixed in 0.3.0