by Michael S. Kaplan, published on 2005/11/25 04:01 -05:00, original URI: http://blogs.msdn.com/b/michkap/archive/2005/11/25/494976.aspx
Recently, Eman asked in the newsgroups:
Please help me clear up general LCID logic.
As far as i understand the SORT_xx values make sense in a pair with PrimaryLanguage only. In other words, a Sort ID has the same meaning for a set of LCIDs where PrimaryLanguage is the same but SubLanguages differ. Is this correct?
I had to be the bearer of bad news, unfortunately:
No, that is not the case.
Sort ID's mske sense with specific LANGID values for which there are supported sorts. It has nothing to do with primary language ID alone.
And this is an important distinction -- for example, 0x0407 is German - Germany, and 0x0807 is German - Switzerland. You can get them by using:
but if you wanted to use German phone book alternate sort, then only the following will work:
MAKELCID(MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN), SORT_GERMAN_PHONE_BOOK)
because it is not defined for any of the other German language locales.
Eman then asked a follow-up question:
Thank you for answer.
So, to let the user choose a sort within specific LangID i can EnumSystemLocales with LCID_INSTALLED | LCID_ALTERNATE_SORTS, filtering out items with the LangID.
Please correct if i am wrong again.
Now this answer is not wrong, but it is a lot more work than is needed. To get the list of alternate sorts available within a specific LANGID there are two methods:
Which method to choose? Well at the moment method #1 may perhaps seem faster since there are way fewer than 15 alternate sorts across all locales, but method #1 returns strings and converting all of those strings to numbers so you can compare them in the locale macros may be more expensive than comparing 15 numbers. Both operations are fast enough that it is one of those silly interview questions to make a candidate answer as to which method is better.
Personally, I would choose method #2 since the future could have more alternate sorts in it (one never knows!) and I like to avoid dealing with strings when I can. But if that were an interview question I were given, I would be sure not to take that particular job.... :-)
This post brought to you by "Ɣ" (U+0194, a.k.a. LATIN CAPITAL LETTER GAMMA)
# Richard on 30 Nov 2005 7:23 AM:
# Tatiana Racheva on 24 Apr 2008 12:41 PM:
So for Vista & later, sounds like one should use EnumSystemLocalesEx, because it will also include Traditional Spanish sort when you use LOCALE_ALTERNATE_SORTS. It seems like you still have to make a special case for it, because you can't derive the same language ID from the two LCIDs...
2005/11/26 Technically it *is* a hungarian sort
go to newer or older post, or back to index or month or day