Jump to content
  • Advertisement
Sign in to follow this  
jbguil09

[SlimDX] CultureInfo for float.TryParse in SmdLoader

This topic is 3168 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

The CultureInfo is not set in the SampleFramework, so the TryParse in SmdLoader return false if your default CultureInfo as not "0.00000" format for float. (Mine is "0,0000"). I just add Thread.CurrentThread.CurrentCulture = new CultureInfo("en-us"); Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-us"); in the run function of the SampleFramework

Share this post


Link to post
Share on other sites
Advertisement
Hmm, yes, since the SMD sample file uses a decimal seperator of ".", I suppose we should probably set the culture or at least use the other try/format.

If you are using the latest (or the SDK) then simply change line 108 of SmdLoader.cs from

if (!float.TryParse(value, out result)) {

to

if (!float.TryParse(value, Numberstyles.Float, CultureInfo.GetCultureInfo("en-us").NumberFormat, out result)) {

Share this post


Link to post
Share on other sites
Would it be preferred to use CultureInfo.InvariantCulture instead of CultureInfo.GetCultureInfo("en-us")?

Share this post


Link to post
Share on other sites
Quote:
Original post by kanato
Would it be preferred to use CultureInfo.InvariantCulture instead of CultureInfo.GetCultureInfo("en-us")?

Yes, that should work as well, as I believe the InvariantCulture is assumed to be an "English" culture and hence will use "." as the decimal separator and "," as the group separator.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!