by Michael S. Kaplan, published on 2005/07/16 11:30 -04:00, original URI: http://blogs.msdn.com/b/michkap/archive/2005/07/16/439603.aspx
A few weeks ago, Ivo asked in the microsoft.public.win32.programmer.international newsgroup:
I was wondering what is the point of the LeadingZero member in NUMBERFMT and CURRENCYFMT. The fact is that GetNumberFormat and GetCurrencyFormat do not have an argument to specify the width of the output, just the size of the buffer. Leading zeros only make sense if I can specify the width of the result somehow. I tried passing GetNumberFormat a source string with leading zeros, but it just ignores them regardless of the LeadingZero flag in NUMBERFMT.
The fact is that the LOCALE_ILZERO LCTYPE in GetLocaleInfo and the LeadingZero member of the CURRENCYFMT and NUMBERFMT structures (used by the GetCurrencyFormat and GetNumberFormat functions, respectively) are described in a way that can easily lead a reasonably intelligent developer to come to the same conclusion that Ivo did:
NUMBERFMT.LeadingZero
Specifies whether to use leading zeroes in decimal fields. This is equivalent to the locale information specified by the LCTYPE constant value LOCALE_ILZERO.CURRENCYFMT.LeadingZero
Specifies whether to use leading zeroes in decimal fields. This is equivalent to the locale information specified by the LCTYPE constant value LOCALE_ILZERO.LOCALE_ILZERO
Specifier for leading zeros in decimal fields. The maximum number of characters allowed for this string is two. The specifier can be one of the following values:
0 No leading zeros
1 Leading zeros
Now the meaning of the LOCALE_ILZERO flag (which, as the documentation for the structs states, applies to both the number and currency formats -- LOCALE_ILMONZERO is all about months, not money!) is not giving permission for there to be numbers like 0000.50.
It is meant to distinguish between .50 and 0.50. It is to allow the often locale-specific preference for one form or the other to be expressed for a given number. Note the plural forms on both sides of the sentence:
Specifies whether to use leading zeroes in decimal fields
Yes, it does talk about multiple zeroes. But it also is talking about multiple numbers. It only means to imply one leading zero per number, a fact that is easy to not see, even if English is one's first language (if it is not then there are even more reasons to possibly not get the admittedly unclear implied message here).
So I think we can all agree that the language is ambiguous here. Even if you understood the meaning yourself, you can almost certainly see the alternate interpretation and how someone might think that is the meaning.
It would be interesting to see if there is some pattern in the way people interpret the text, and whether it correlates with their original native language. It would also be fascinating to know what translated versions of the Platform SDK say here -- whether the localizer made the same mistake in interpretation, or whether they let the same ambiguity span the language barrier and exist in the localized version.
On the other hand, it would be fascinating to know if there were localized versions of the Platform SDK (all of the ones that ship with various language versions of products seem to be in English; I guess they dodged that bullet!).
This post brought to you by "ريال" (U+0631 U+064a U+0627 U+0644, a.k.a. Rial as in the Iranian Rial)
a currency that seldom requires one to care about leading zeroes since the currency values are generally not fractional
# Luke on 16 Jul 2005 1:45 PM:
# Michael Dunn_ on 17 Jul 2005 7:57 PM:
# Michael S. Kaplan on 17 Jul 2005 10:12 PM:
referenced by