Bug 40697 - Some NumberFormat have wrong GroupSeparator
Summary: Some NumberFormat have wrong GroupSeparator
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib ()
Version: master
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2016-04-26 11:44 UTC by Robert van der Boon
Modified: 2016-05-04 13:28 UTC (History)
2 users (show)

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

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 Robert van der Boon 2016-04-26 11:44:59 UTC
In some culture we get a roundtrip error when we ToString/Parse using the {0:N} format.
This is probably due to the fact that on Mono for these cultures the same string is defined as both NumberDecimalSeparator as NumberGroupSeparator.

In the Mono csharp REPL the following script:
using System.Globalization;
foreach(var culture in CultureInfo.GetCultures(CultureTypes.SpecificCultures))
  if (culture.NumberFormat.NumberDecimalSeparator == culture.NumberFormat.NumberGroupSeparator)
    Console.WriteLine("Culture error: {0} (decimalSep:'{1}', groupSep:'{2}')", culture.Name, culture.NumberFormat.NumberDecimalSeparator, culture.NumberFormat.NumberGroupSeparator);

outputs:
Culture error: tg-Cyrl-TJ (decimalSep:',', groupSep:',')
Culture error: hy-AM (decimalSep:'.', groupSep:'.')
Culture error: km-KH (decimalSep:'.', groupSep:'.')
Culture error: lo-LA (decimalSep:'.', groupSep:'.')
Culture error: sah-RU (decimalSep:',', groupSep:',')
Culture error: ar-LY (decimalSep:'.', groupSep:'.')
Culture error: ar-TN (decimalSep:'.', groupSep:'.')
Culture error: ar-LB (decimalSep:'.', groupSep:'.')

Whereas on plain .Net this outputs nothing.


The result is that the following code works for both cultures on .Net framework, while it fails on mono for (in this example) tg_Cryl_TJ:
double v = 123456.789;
var ciNL = System.Globalization.CultureInfo.CreateSpecificCulture("nl-NL");
var ciTJ = System.Globalization.CultureInfo.CreateSpecificCulture("tg-Cyrl-TJ");
double.Parse(v.ToString("N", ciNL), ciNL); // Succeeds on .Net and Mono
double.Parse(v.ToString("N", ciTJ), ciTJ); // Succeeds on .Net, throws FormatException on Mono


NOTE: On the .Net framework (windows 7 x64) the definition for the failing cultures is:
tg-Cyrl-TJ (decimalSep:',', groupSep:' ')
hy-AM (decimalSep:'.', groupSep:',')
km-KH (decimalSep:'.', groupSep:',')
lo-LA (decimalSep:'.', groupSep:',')
sah-RU (decimalSep:',', groupSep:' ')
ar-LY (decimalSep:'.', groupSep:',')
ar-TN (decimalSep:'.', groupSep:',')
ar-LB (decimalSep:'.', groupSep:',')
i.e. the group separator on mono is different from .Net framework
Comment 1 Marek Safar 2016-05-04 13:28:52 UTC
Fixed in master