Number format and currency format are not always the same

by Michael S. Kaplan, published on 2005/06/21 05:51 -04:00, original URI:

Almost a month ago I was talking about how GetCurrencyFormat and GetNumberFormat take strings for their number parameters and why. And John Bates commented:

One of my web forms (an invoice) has a column of currency amounts with a total at the bottom. The customer prefers to have the currency symbol only on the total.

So I should really be using GetCurrencyFormat for all the numbers, but have to use GetNumberFormat to get a string without the currency symbol.

So my question is: Does the number format for any locale differ from its currency format, with the exception of the symbol?

The answer to that question is that there are indeed locales where they are different, indeed that is the reason that all of the settings between the two are kept separate.

The PMs who work with customers and governments and subsidiaries know that the ramifications of adding an LCTYPE to GetLocaleInfo, especially one that will affect other functions and parsing/formatting rules in Windows or the .NET Framework, keep them from ever adding LCTYPEs without having proof that they are needed. It is in fact why sometimes the names do not seem 100% consistent (e.g. there is a LOCALE_SDECIMAL and then there is a LOCALE_SMONDECIMALSEP). The latter was added because it became clear that there are sometimes differences....

And this is an ever-evolving issue. For example, when all of the various percentage formats were added for the .NET Framework, a lot of the data was always identical to the numeric formats, so extra data fields were not added for them. But as data comes in that there are differences in some cases (as it has been), then the decision on what fields to add has to be made....

Sorry, John. You may want to find a better way to get the data....


This post brought to you by "㉧" (U+3267, a.k.a. CIRCLED HANGUL IEUNG)

# Meikel Weber on 21 Jun 2005 6:50 PM:

> So my question is: Does
> the number format for any locale
> differ from its currency format,
> with the exception of the symbol?

Just download this one here:

Not release quality software, not very beautiful, not code signed, but made for questions like this one. I built it while I was examining the whole international features of Windows.
Should run from 95 to 2003 just fine.

# John Bates on 21 Jun 2005 7:18 PM:

That's what I thought.

So GetCurrencyFormat really needs a new associated API to retrieve the CURRENCYFMT structure for a specified locale, with flags to turn off currency symbols, etc. GetNumberFormat and GetDateFormat may also benefit from similar functions.

Are there any plans to add something similar to Longhorn? Can we also ask the owner of the GetXxxFormat functions to create a sample for MSDN that builds XxxFMT structures from the GetLocaleInfo results (especially for downlevel systems)?

# Michael S. Kaplan on 22 Jun 2005 12:21 AM:

Hi John --

I can forward the suggestion on, it is a good one.

On the whole, I am not sure it is worth adding flags to change behavior.

If I were designing something here, I would probably not add a function at all -- I would add a flag to "fill in data not provided by the caller in the struct, from the locale."

This would save people the trouble of having to call two functions....

Please consider a donation to keep this archive running, maintained and free of advertising.
Donate €20 or more to receive an offline copy of the whole archive including all images.

referenced by

2012/09/24 NOTE TO SELF: Not every team in Microsoft does things the same way...

2011/02/18 speaking with an accent, conceptually

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

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