Bug 24685 - float.Parse or double.Parse throw Format Exception in device
Summary: float.Parse or double.Parse throw Format Exception in device
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: XI 8.0.0
Hardware: Other Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2014-11-20 00:44 UTC by heebaek choi
Modified: 2014-11-20 08:48 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

screenshot (309.29 KB, image/png)
2014-11-20 00:45 UTC, heebaek choi

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description heebaek choi 2014-11-20 00:44:10 UTC
i am korean, this bug is fired only when i changed my device's language to another language(i am changed to france).
and only in real device not simulator. (i tested iPhone 4s, os version = 8.0.2(12A405), language is france and country is korea)
reproduce step is very simple.

just create single view application and in a main.cs

in main function just add one line.

var test = float.Parse("1.1f");

i think "."(dot) cause exception because if i test float.Parse("1"), or double.Parse("1") without "."(dot) exception is not occured.

i hope to help xamarin to better. thanks.
Comment 1 heebaek choi 2014-11-20 00:45:35 UTC
Created attachment 8816 [details]
Comment 2 Sebastien Pouliot 2014-11-20 08:48:58 UTC
Yes, that's normal. You'll have the same behaviour if you run this in a Windows apps using MS .NET on a French computer. That's because some culture interpret the same characters differently (e.g. ',' can separate decimals or thousands).

If your application has hard-coded strings, like "1.1", then you cannot trust the current culture to be able to parse it. In such case you need to specify a culture where the string is valid, e.g.

	var test = float.Parse("1.1", System.Globalization.CultureInfo.InvariantCulture);

^ this will work, even if the device is configured to use French