views:

94

answers:

1

We have code in our system to format numbers and currency according to the regional settings selected by the user. One of our users has selected en-ZA and noticed that the digit grouping and decimal separators have changed with our migration to .NET 4.0.

I wrote a snippet of code to illustrate this change:

using System;
namespace regional
{
    class Program
    {
        static void Main(string[] args)
        {
            var ci = new System.Globalization.CultureInfo("en-ZA");
            var output = 1234567.00m.ToString("c", ci);
            Console.WriteLine(output);            
        }
    }
}

Under .NET 3.5, we get output that looks like this:

R 1,234,567.00

Under .NET 4.0, we get output that looks like this:

R 1 234 567,00

What accounts for the change in decimal separator and digit grouping between .NET 3.5 and .NET 4.0?

According to Wikipedia, "When South Africa adopted the metric system, it adopted the comma as its decimal separator." This implies that this setting changed at some point, but I still don't have insight as to why the behavior is different between the different framework versions.

A: 

The .net team review stuff like this based on consumer feedback - presumably enough people petitioned them to say the existing settings were incorrect so they changed them.

http://msdn.microsoft.com/en-us/library/dd997383.aspx#updated_globalization_property_values

basically says "we update globalization settings between versions", and

http://msdn.microsoft.com/en-us/library/dd997383.aspx#getting_current_globalization_information

says that from Windows 7 onwards they in fact load globalization data from the OS (so potentially en-za will appear differently under different operating systems, at different points in time). Also

Because of the ever-changing world, globalization information is subject to change at any time; developers should not expect the values of globalization properties to persist between releases, or even for the same release of the .NET Framework

Tom Carver
Thanks for the answer. My guess is that if a particular customer wants a different set of formatting rules that are no longer available for en-ZA, I'm going to have to figure out how to support a custom CultureInfo.
Bernard Chen
It looks that way, and possibly that you'll have to do that even if they just want a *consistent* set of formatting rules - we're all potentially one windows update away from a change in these settings (from Win 7 onwards)!
Tom Carver