Bug 18830 - Double.Parse FormatException in german locale
Summary: Double.Parse FormatException in german locale
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib ()
Version: 3.2.x
Hardware: Other Linux
: --- normal
Target Milestone: Untriaged
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2014-04-06 04:00 UTC by sw
Modified: 2014-04-07 11:56 UTC (History)
3 users (show)

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


Attachments
a little testcase (5.50 KB, application/octet-stream)
2014-04-06 04:00 UTC, sw
Details


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 GitHub or Developer Community 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:
Status:
RESOLVED FIXED

Description sw 2014-04-06 04:00:37 UTC
Created attachment 6505 [details]
a little testcase

I have a raspberry pi (os: raspbian) with system language set to "de_DE.UTF-8" and mono version 3.28 installed. My programs need to convert Strings into Doubles, but I ran into a few problems:

Double.Parse("500", NumberStyles.Float, CultureInfo.InvariantCulture);

Works just fine.

Double.Parse("500.123", NumberStyles.Float, CultureInfo.InvariantCulture);

Throws FormatException, what is weird.

Double.Parse("500,123", NumberStyles.Float, CultureInfo.GetCultureInfo("de-DE"));

Throws FormatException too;

The funny thing is if I change my system language (raspi-config and reboot after that) to "en-GB.UTF-8" all functions work as expected. As a German user I would like to use German system settings.

I looked into the source of Double.cs ( https://github.com/mono/mono/blob/master/mcs/class/corlib/System/Double.cs ). I think that line 533 to 537 are doing this:
if (!ParseImpl (p, out retVal)) {
  if (!tryParse)
    exc = Int32.GetFormatException ();
  return false;
}
But I can´t find the code for ParseImpl it is some a extern function.

I added a testcase as attachment

mono --version:
Mono JIT compiler version 3.2.8 (Debian 3.2.8+dfsg-4+rpi1)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
	TLS:           __thread
	SIGSEGV:       normal
	Notifications: epoll
	Architecture:  armel,vfp+hard
	Disabled:      none
	Misc:          softdebug 
	LLVM:          supported, not enabled.
	GC:            sgen
Comment 1 Marek Safar 2014-04-07 11:56:09 UTC
Already fixed in mono 3.4