by Michael S. Kaplan, published on 2006/01/24 06:01 -05:00, original URI: http://blogs.msdn.com/b/michkap/archive/2006/01/24/516661.aspx
The title quote was said by the most famous person to ever write a post for this blog. :-)
It came up earlier today when someone was asking about InvariantCulture (names changes to protect the guilty):
I found a good summary on string comparisons and InvariantCulture at: http://team/sites/NETSecurity/Shared%20Documents/String%20Issues/New%20Recommendations%20for%20Using%20Strings%20in%20.NET%202.0.mht.
What about culture agnostic data handling? The __________ team is using en-US for serialization instead of InvariantCulture based on current limitations of the latter. Is there a document that lists the current limitations and/or a comparison of InvariantCulture with en-US?
Is the current guidance to abandon InvariantCulture (with the exeption of the cases listed in the above document) and use en-US for all internal AND culture agnostic data handling?
When you think about the reasons the Invariant locale exists (cf: Where is the locale? It's Invariant. In where?), this is a somewher ironic turn of events, isn't it?
I mean, think about how the problem was in the perception of recommending that people use 0x0409/en-US when they wanted something arbitrary, and the solution was to provide something arbitrary. A way to not be quite so provincial.
But then when it comes down to the time to make the decision, it is the very arbitrary nature of the data that works against Invariant, so people go right back to 0x0409/en-US for their locale/culture needs. All on the basis that a document suggests that people should stay away from Invariant when they ought to be using Ordinal or OrdinalIgnoreCase for comparisons.
In actuality, 0x0409/en-US is a terrible choice here -- because if the preferences of people in this country change and a new preferences emerges, the data will be changed. In other words, the en-US CultureInfo follows the cultural preferences of those English speaking people in the United States of America. Which are completely subject to change.
Not a great base for arbitrary or for culture-agnostic operations, by any means!
Let's go back to that quote for a minute:
Invariant is a really good choice any time there is no better choice.
Easy rule, just keep in mind:
It is pretty easy to decide what bucket your code falls into if you know what the code does....
But don't rely on en-US -- here in the USA, we elect B-movie actors for president and action movie stars for governor. Would you really want to rely on this country for its cultural preferences? I know I wouldn't! :-)
This post brought to you by "Ｉ" (U+ff29, a.k.a. FULLWIDTH LATIN CAPITAL LETTER I)
2006/05/24 Invariant vs. Ordinal, the third
go to newer or older post, or back to index or month or day