This content has moved to another location. See LCMapString for the latest version.
LCMapStringEx is preferred
Try to avoid LCIDs and use locale names if possible
Users can create custom locales which your application may not have access to if it doesn't use the locale name. Custom locales don't get their own LCIDs, so functionality is limited if your application relies on the LCID. See this blog http://blogs.msdn.com/shawnste/pages/custom-cultures-vista-custom-locales.aspx for more info about locales/custom locales and good behavior with locales.
Note that the sort key wasn't ever designed to be parsed or undone, so there are edge cases and the like that would make a dependency on the sort key structure scary. It is safe to know that its null terminated, but that's about all you can take for granted.
I also wouldn't ever use byte reveral with a sort key :)
Sort keys are basically binary arrays of bytes. You have to be careful about the lengths when testing them. The first byte difference is the actual difference between keys. If one is a substring of the other, then the shorter one sorts first.
int CompareSortKeys(PBYTE key1, size_t length1, PBYTE key2, size2 length2){ int result; // Test only the portion that overlaps int testLength = min(length1, length2); int result = memcmp(key1, key2, testLength); // If one is a substring of the other, the longer one is greater if (result == 0) { // Longer one is greater if (length1 < length2) return CSTR_LESS_THAN; if (length2 > length1) return CSTR_GREATER_THAN; // Otherwise equal Return CSTR_EQUAL;}// Not equalreturn result < 0 ? CSTR_LESS_THAN : CSTR_GREATER_THAN;}
(I HAVEN’T TESTED THE EXAMPLE ABOVE)