Decimal vs. hexadecimal LCIDs, backcompat, and being weird

by Michael S. Kaplan, published on 2006/08/21 06:01 -04:00, original URI: http://blogs.msdn.com/b/michkap/archive/2006/08/21/707790.aspx


The other day, developer Jamie Laflen had a question which VSTS International Program Manager Aldo Donetti forwarded on to me:

I have a test that enumerates all collations in SqlServer and verifies that the string generator can, well, generate strings for each of them.

I hit a weird case for collation:
Georgian_Modern_Sort_BIN

When I run the following:

    declare @collation as varchar(60)
    select @collation = 'Georgian_Modern_Sort_BIN'
    SELECT COLLATIONPROPERTY( @collation, 'LCID')


It returns 66615 for the LCID.

If I then call CultureInfo.GetCulture(66615) it returns a culture "ka-GE."  If I then call CultureInfo.GetCulture( "ka-GE" ) it returns a CultureInfo with the LCID == 1079

This is pretty weird.

I did find that the TextInfo object for both CultureInfo instances has its LCID property equal to 1079 (i.e. culture.TextInfo.LCID).  For the time being, I changed the code to use the property TextInfo.LCID, but it would be good to understand what is going on here.

Does this make sense?  Any ideas?

Jamie

Aldo agreed, saying:

Weird, but I suspect Michael will have an explanation for it. 66615 was already mentioned as the LCID for Georgian in his article on SQL2k Intl. features (now offline but can be downloaded here) so it’s nothing new, but in this page it’s not listed.

I’d agree with your action of using the LCID from the CultureInfo object but I’m very curious to know what 66615 is …

Once again, the SQL Server/DevDiv preference for decimal LCIDs affects developer productivity! :-)

If you look at the hexadecimal numbers, 1079 and 66615 become 0x0437 and 0x10437, the Traditional and Modern Georgian sorts that I have discussed previously....

In .NET 2.0, you can try using CultureInfo.CompareInfo.LCID and CultureInfo.CompareInfo.Name to get back the 0x10437 and ka-GE_modern that you would want here if getting back the right identifier was important. Although CultureInfo.LCID will also return 0x10437, CultureInfo.Name has to return ka-GE for backward compatibility with prior versions of the .NET Framework (and believe me when I tell you this unusual compromise that came out of the argument of LCID/name consistency vs. cross-version consistency was hotly debated at the time!).

The fact that all of this came up in a Unicode only locale (Georgian) in a unit test involving a SQL Server _BIN (binary) sort which means that there is no actual sorting or code page difference of consequence in this sort and that all results will be identical to the Latin1_General_BIN results is of course a separate a point that is interesting to me for the same reason that people discussing the difference between German, Dutch, and English sorting on Windows is.

Ah, the irony of discussing a difference that makes no difference. :-)

On an unrelated note, Aldo has a point here, which I will take to its logical conclusion. The fact that this is the sort of question that I know the answer to is something that I think makes me weird, too!

 

This post brought to you by (U+10f4, a.k.a. GEORGIAN LETTER HAR)


# win.sight on 21 Aug 2006 7:51 AM:

Hey, I want to know whether Vista will ship with Unicode 5.0. From what I've heard, it wont.

# Michael S. Kaplan on 21 Aug 2006 8:02 AM:

Hmmm.... seems pretty offtopic here. Why not try the Suggeston Box?

# Aldo Donetti on 21 Aug 2006 12:39 PM:

Not sure *that* is where I was going with my comments ... ;-)
But your long time experience in the field makes it almost a certainty that you would know the answer to any (even weird) question - thanks!
Aldo

# Dean Harding on 21 Aug 2006 7:57 PM:

xpclient: Michael has answered this question already: http://blogs.msdn.com/michkap/archive/2005/12/23/506887.aspx

Actually looking over that old post reminds of this hilarious quote from the latest Pink Panther movie (which I watched on a plane, and was otherwise rather uninspired). It was at a press conference, and a member of the press was asking a question:

Press: Do you think the killer was a man or a woman?
Clouseau: Well of course it was! What do you think it was, a kitten?

How's THAT for off-topic :p~

# Maurits [MSFT] on 21 Aug 2006 9:42 PM:

s/hexidecimal/hexadecimal/

# Michael S. Kaplan on 21 Aug 2006 10:57 PM:

Hmmm, I can't find any examples that are broken, I guess that must be a typo in the comment?

j/k :-)

referenced by

2011/10/21 Yet another time they messed up. Respectfully.

2006/09/06 IsSortable() == false? Well, sometimes it may be lying....

2006/08/26 The myth of cross-product compatibility

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