And you can't set all of the properties all of the time...

by Michael S. Kaplan, published on 2005/11/24 04:01 -05:00, original URI: http://blogs.msdn.com/b/michkap/archive/2005/11/24/495349.aspx


There is some sort of implicit belief that if a locale property is settable that it should be set.

Up to and including the .NET Framework 2.0, there are a few of the properties that violate that belief in the NumberFormatInfo class and that should not be set:

I should probably back up a second and explain when they are meant to be set, and more importantly when setting them will not actually accomplish anything.

These four properties can be set any time you are using a NumberFormatInfo object to do work. The first three will affect percent formatting and parsing, while the last one will do very little at all.

These four properties should not be set on the NumberFormat hanging off the CultureAndRegionInfoBuilder class.

Well, you can set them if you want. But the values you set will not be persisted in the custom culture. So setting them when you are creating a custom culture will not actually accomplish anything. So why spend the time?

The rules whereby the values are set vary for each property:

  • PercentGroupSizes -- takes the value from NumberGroupSizes
  • PercentDecimalDigits -- takes the value from NumberDecimalDigits
  • PercentGroupSeparator -- takes the value from NumberGroupSeparator
  • PerMilleSymbol -- always starts as U+2030

    The reasons? Well, I am not sure who uses the PerMilleSymbol so I do not know for sure, but I would guess that the reason is the same as the other three properties: that there is no locale/culture that we know of that reports a different value for these properties.

    Until/unless that changes, these are four properties that you should not try to set in your custom cultures....

     

    This post brought to you by "‰" (U+2030, a.k.a. PER MILLE SIGN)


  • # Mihai on 25 Nov 2005 6:32 AM:

    "there is no locale/culture that we know of that reports a different value for these properties"

    Isn't this the whole idea or custom locales, to add support for locales that you don't know of?

    Because you have never seen a locale with different values for those properties, nobody should be able to create one.

    I am not sure this is such a good idea.

    # Michael S. Kaplan on 25 Nov 2005 10:30 AM:

    A very excellent point, Mihai....

    Truth be told I am not even 100% sure that the information we have that it is never different for our current locales is 100% accurate, either. :-)

    I am reasonably sure that this will change in the future, though it may need the report of the culture that does this to actually have that happen....

    referenced by

    2010/08/30 A difference that makes no difference shouldn't make a difference, but...

    2005/12/11 Why does the percent stuff have so many restrictions?

    2005/12/11 More limitations with percentage support

    go to newer or older post, or back to index or month or day