Freigeben über


PROPVARIANT Helpers #7 - Locale sensitivity and the helper APIs

As I went through the property helper posts, I kept using those dense word combinations "locale sensitive" and "locale insensitive". Why?

Because locale tells your computer whether to display a number as "5.3" or "5,3". Should "5,305" be a big number or a little one? Locale governs type conversions and sorting. Since the property system deals with type conversions often, locale becomes an important factor in the API set. 

The property system mainly concerns itself with data flow. It must be able to get data from point A to point B regardless of the language the user speaks. Therefore, most property APIs are locale insensitive. That is, they perform conversions that don't correspond to any language, but are consistent and portable. Thus PropVariantToString will return dates like "2006/09/26:06:27:00.000". This is data which can be placed into a file, transported to Germany and still be interpreted by the computer.

There are also approximately two APIs that perform locale sensitive work. These are PSFormatForDisplay and PropVariantCompare. The former spits out a string in the user's current language ("9/25/2006 11:27 PM" for me) while the later, well, compares things.

So just remember that if you want a string for display, use PSFormatForDisplay. If you want to transport data, use just about any other helper.

-Ben Karas

ps. I use the terms locale-invariant and locale insensitive interchangibly. Personally, I wish there was a more distinguishable wording. The 'in' in insensitive can get lost in the mess of letters.

pps. If you want a deep discussion about locales and the APIs that obey their dictates, you should mosey over to Michael Kaplan's blog.

Comments

  • Anonymous
    November 05, 2006
    This coding expedition has developed a tool that can dump out all the properties on a file. If you are