为什么 en-ZA 的数字分组和小数点分隔符从 .NET 3.5 更改为 .NET 4.0?

发布于 2024-09-11 00:46:20 字数 799 浏览 4 评论 0 原文

我们的系统中有代码可以根据用户选择的区域设置来格式化数字和货币。我们的一位用户选择了 en-ZA,并注意到数字分组和小数点分隔符随着我们迁移到 .NET 4.0 而发生了变化。

我编写了一段代码来说明这一变化:

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);            
        }
    }
}

在 .NET 3.5 下,我们得到如下所示的输出:

R 1,234,567.00

在 .NET 4.0 下,我们得到如下所示的输出:

R 1 234 567,00

What account for the change in Decimal Separator and Digit Grouping between . NET 3.5 和 .NET 4.0?

根据维基百科,“当南非采用公制时,它采用逗号作为小数点分隔符。”这意味着这个设置在某个时候发生了变化,但我仍然不明白为什么不同框架版本之间的行为不同。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

站稳脚跟 2024-09-18 00:46:20

.net 团队根据消费者反馈审查此类内容 - 大概有足够多的人向他们请愿,说现有设置不正确,因此他们进行了更改。

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

基本上表示“我们更新版本之间的全球化设置”,并且

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

表示,从 Windows 7 开始,它们实际上从操作系统加载全球化数据(因此可能会za 在不同的操作系统、不同的时间点会以不同的方式出现)。还

由于世界瞬息万变,全球化信息随时发生变化;开发人员不应期望全球化属性的值在各个版本之间持续存在,甚至对于同一版本的 .NET Framework 也如此

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文