The many faces of CultureInfo

by Michael S. Kaplan, published on 2005/02/22 20:40 -05:00, original URI:

The March 2005 issue of MSDN Magazine is now online, and it contains an article written by yours truly. The article is entitled Make the .NET World a Friendlier Place with the Many Faces of the CultureInfo Class and attempts to capture many of the possible uses of CultureInfo (and how to choose the correct one to use in a managed application).

It is interesting how the article came about. Stephen Toub is a man who tends to prove wrong the (unfair) conventional notion of an editor since he is pretty astute technically. Maybe this explains why his title is "Technical Lead" and not "Editor" although he does work for Joshua Trupin, the Executive Editor of MSDN Magazine (and the guy who I have written articles for in the past). Anyway, Stephen often answers technical questions internally on Microsoft aliases. He and I tend to cross paths a whole lot since we hang out on the same aliases. After a particular question I had answered we started talking about how it clear that the "which culture should I use?" question was pretty commonly asked, and that perhaps a short piece that would try to go through the various uses and how to pick the right one in each case could come in handy.

Before you knew it, there was an article. :-)

Anyway, there are several interesting topics that I have covered here in various ways and others that I have not (yet). Hope you enjoy....


This post brought to you by "٪" (U+066a, a.k.a. ARABIC PERCENT SIGN)

# AC on 22 Feb 2005 8:09 PM:

So, can you get paid for doing these articles?

# Michael Kaplan on 22 Feb 2005 8:37 PM:

I don't think so (though they used to pay me when I was not a fulltime employee). I'm not really sure.

It was not that much money though. This stuff is fun to do for its own sake. :-)

# Uwe Keim on 22 Feb 2005 9:08 PM:

I see, the MSDN-Mag article was not sponsored by any Unicode-character. Any excuses for that? :-)

# Michael Kaplan on 22 Feb 2005 9:41 PM:

Well, sponsorship in an article is a much bigger deal -- characters mostly try to stay out of the limelight due to their shy natures!

# Matthew W. Jackson on 23 Feb 2005 9:37 AM:

Very informative article, but I've reread it twice and I'm still not completely understanding the difference between Current Culture and Current UI Culture.

Does one apply only the the base "language" setting in the OS, and does not have anything to do with the user's regional preferences overrides?

I guess my problem is that I've only used US English, and about the only regional setting I ever change is putting the date format into (Too bad I have to change this if I want to import QIF files from my bank into MS Money, since Money uses current regional settings for imported dates---but if my bank would use OFX then there wouldn't be a problem---this is really a QIF spec problem, IMO).

But I always want to code my apps internationally, even if I know they'll only be used in the US. I want to respect the user's settings, so, when I format a value and want it to display like the user wants, do I use Current UI Culture?

If so, what's the real point of Current Culture? For talking to the OS?

# Michael Kaplan on 23 Feb 2005 11:11 AM:

No, current culture is to get the user's preferences for things like how dates and numbers get formatted, how lists should be sorted, and such.

The UI Culture is to get the localization correct -- but it assumes you have localized content in a language (you may not)....

# Matthew W. Jackson on 23 Feb 2005 6:46 PM:

Okay, that makes much more sense. This is in the docs, but I've never seen a side-by-side comparison of the two.

The part I didn't realize until now is that when you read a resource string that has "{0}" placeholders, and then call String.Format to insert the values, you're actually using two different CultureInfo objects.

# Michael Kaplan on 15 Mar 2005 6:23 AM:

Also available as a downloadable .CHM file... see Stephen's article at

referenced by

2006/12/14 In the new MSDN Magazine -- Unicode and Microsoft, and Vista

2005/06/24 多機能な CultureInfo クラスを利用して .NET の世界を身近なものにする

2005/06/24 Многоликий класс CultureInfo — .NET-приложения станут дружелюбнее к пользователю

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