Bug 59215 - Single.TryParse returns true for empty string when using Czech locale
Summary: Single.TryParse returns true for empty string when using Czech locale
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib (show other bugs)
Version: 5.4 (2017-06)
Hardware: PC Mac OS
: --- normal
Target Milestone: Future Release
Assignee: Bugzilla
Depends on:
Reported: 2017-09-04 17:00 UTC by Matt Ward
Modified: 2017-09-04 21:09 UTC (History)
2 users (show)

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

TestSingleConversionProject (7.40 KB, application/zip)
2017-09-04 17:00 UTC, Matt Ward

Description Matt Ward 2017-09-04 17:00:08 UTC
Created attachment 24560 [details]

Mono version: (2017-06/6b8abfeb7cc Thu Aug 17 18:17:27 EDT 2017)

The following code (also provided in the attached zip as a project) uses Single.TryParse to parse an empty string. When the machine's locale is set to Czech 'cs-CZ' the TryParse returns true. On Windows it returns false.

string culture = "cs-CZ";
Thread.CurrentThread.CurrentCulture = new CultureInfo (culture);

string text = "";
Single number;
bool result = Single.TryParse (text, out number);

// result should be false but it is true for 'cs-CZ' culture.
Console.WriteLine (result);
Comment 1 Marek Safar 2017-09-04 21:09:17 UTC
This is coming from referencesource which assumes that no culture has empty numeric symbols (e.g. NaN)

Note You need to log in before you can comment on or make changes to this bug.