none
Suddenly no more group seperator for culture "pt-PT" in CLR 4 + Win8 RRS feed

  • Question

  • Hello

    We had a couple of integration tests that were failing on a Windows 8 Development machine. We have decimals that we need to format using the Portugese culture (pt-PT) and they need to be displayed as:

    9.999.999,99

    This all works fine in all version of the .NET Framework in Windows 7 but in Windows 8, when we target .NET Framework 4.0 or higher we get as the group seperator for the culture "pt-PT" an empty space. The funny thing is that on the same machine when we target .NET Framework 3.5 or earlier we still get a "." as the group seperator.

    Can this somehow be explained?

    Regards

    Tuesday, November 27, 2012 8:26 AM

Answers

  • Are you suggesting that both .NET 4.0 and 4.5 (same behavior here) got it all wrong, while .NET 3.5 got it right? - Given the pictures above, I'll strongly advocate to the opposite. The operating system is always right.

    When you set the current thread's culture to "pt-PT", Thread.CurrentThread.CurrentCulture.NumberFormat.NumberGroupSeparator will yield a space character both in 4.0 and 4.5, and this is exactly what the Windows 8 regional settings dialog from above shows.

    If you don't need the system's default, you can always work around the default by writing something like:

    CultureInfo cultureInfoPT = new CultureInfo("pt-PT");
    cultureInfoPT.NumberFormat.NumberGroupSeparator = "."; // just to make sure
    Thread.CurrentThread.CurrentCulture = cultureInfoPT;
    Thread.CurrentThread.CurrentUICulture = cultureInfoPT;

    I'll agree that this is inconsistent with the default regional settings for Portuguese in operating systems ranging from Windows XP to Windows 7.

    Update: There are some hints regarding the use of the space character as a group separator in the Wikipedia article on the decimal mark:

    The problem with the point and the comma as either decimal mark or digit group separator is that, internationally, they have both often been used for both meanings, and their meaning is context-dependent (one must know which notational system is being used in order to interpret them). Therefore the space is recommended in the SI/ISO 31-0 standard, and the International Bureau of Weights and Measures states that "for numbers with many digits the digits may be divided into groups of three by a thin space, in order to facilitate reading. Neither dots nor commas are inserted in the spaces between groups of three".

    Tuesday, November 27, 2012 3:17 PM
  • Hi Gabriel,

    Welcome to the MSDN Forum.

    >>My only concern was the inconsistency between not only the .NET Frameworks but also the Windows operating system. 

    Please report it here: http://connect.microsoft.com/VisualStudio 

    When you finished it, please post the link here.

    Thank you.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, November 28, 2012 10:41 AM
    Moderator
  • Hi,

    Just reported the issue on Microsoft Connect. Please feel free to comment and/or add your voting.

    Marcel

    Wednesday, November 28, 2012 11:43 AM

All replies

  • Hi Gabriel,

    This must be some kind of a Windows 8-related issue.
    When I look into the regional settings for Portuguese, I see that the digit grouping symbol for plain numbers is set to an empty space:

    Regional Settings - Portuguese

    This is not the case for currency:

    Currency Settings - Portuguese

    Marcel

    Tuesday, November 27, 2012 12:21 PM
  • For the culture "pt-BR" I do get a "." and also for "pt" but not for "pt-PT". And like I mentioned on Windows 8 there is difference between the different runtimes.

    Target Framework 4.0

    1) CurrencyGroupSeperator = " "
    2) NumberGroupSeperator = " "

    Target Framework 3.5

    1) CurrencyGroupSeperator = "."
    2) NumberGroupSeperator = "."

    Tuesday, November 27, 2012 1:10 PM
  • Are you suggesting that both .NET 4.0 and 4.5 (same behavior here) got it all wrong, while .NET 3.5 got it right? - Given the pictures above, I'll strongly advocate to the opposite. The operating system is always right.

    When you set the current thread's culture to "pt-PT", Thread.CurrentThread.CurrentCulture.NumberFormat.NumberGroupSeparator will yield a space character both in 4.0 and 4.5, and this is exactly what the Windows 8 regional settings dialog from above shows.

    If you don't need the system's default, you can always work around the default by writing something like:

    CultureInfo cultureInfoPT = new CultureInfo("pt-PT");
    cultureInfoPT.NumberFormat.NumberGroupSeparator = "."; // just to make sure
    Thread.CurrentThread.CurrentCulture = cultureInfoPT;
    Thread.CurrentThread.CurrentUICulture = cultureInfoPT;

    I'll agree that this is inconsistent with the default regional settings for Portuguese in operating systems ranging from Windows XP to Windows 7.

    Update: There are some hints regarding the use of the space character as a group separator in the Wikipedia article on the decimal mark:

    The problem with the point and the comma as either decimal mark or digit group separator is that, internationally, they have both often been used for both meanings, and their meaning is context-dependent (one must know which notational system is being used in order to interpret them). Therefore the space is recommended in the SI/ISO 31-0 standard, and the International Bureau of Weights and Measures states that "for numbers with many digits the digits may be divided into groups of three by a thin space, in order to facilitate reading. Neither dots nor commas are inserted in the spaces between groups of three".

    Tuesday, November 27, 2012 3:17 PM
  • I am fully aware of the workaround, which we use right now and yes in countries such as Portugal, Italy, Spain, Belgium, ... using either a group separator such as " " or "."  are both allowed in printed and in handwritten form.

    My only concern was the inconsistency between not only the .NET Frameworks but also the Windows operating system. If the operating system gets it correct then why is it still not taking it from the operating system when we target .NET Framework 3.5 or .NET Framework 2.0 on Windows 8? You can reproduce this by creating a console application in Visual Studio 2012 that targets any of the .NET Frameworks. Like I have mentioned earlier, as of .NET Framework 4.0 on the exact same machine with the exact same operating system that being Windows 8 we suddenly get a different group seperator which is in my humble opinion very strange and to say the least messed up.

    Tuesday, November 27, 2012 3:57 PM
  • The operating system evolved, the frameworks evolved.

    If the operating system is always right, then we have to conclude that the .NET Framework 3.5 and the pre-VISTA CLR 2.0 are wrong on the group separator issue.

    Tuesday, November 27, 2012 4:09 PM
  • Hi Gabriel,

    Welcome to the MSDN Forum.

    >>My only concern was the inconsistency between not only the .NET Frameworks but also the Windows operating system. 

    Please report it here: http://connect.microsoft.com/VisualStudio 

    When you finished it, please post the link here.

    Thank you.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, November 28, 2012 10:41 AM
    Moderator
  • Hi,

    Just reported the issue on Microsoft Connect. Please feel free to comment and/or add your voting.

    Marcel

    Wednesday, November 28, 2012 11:43 AM
  • Thank you guys for your help.
    Wednesday, November 28, 2012 11:50 AM