Click to Rate and Give Feedback
MSDN
MSDN Library

  Switch on low bandwidth view
LCMapString

This content has moved to another location. See LCMapString for the latest version.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
LCMapStringEx is preferred      Shawn Steele [MSFT]   |   Edit   |   Show History

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.

Tags What's this?: Add a tag
Flag as ContentBug
Upon failure don't trust the output buffer.      Shawn Steele [MSFT]   |   Edit   |   Show History
After failure the output buffer may not contain any results, even partial results and its contents should be considered invalid.
Tags What's this?: Add a tag
Flag as ContentBug
The LCMAP_SortKey option as described above wasn't intended to be parsed.      Shawn Steele [MSFT]   |   Edit   |   Show History

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 :)

Tags What's this?: Add a tag
Flag as ContentBug
To compare sort keys you'd have to do something like this:      Shawn Steele [MSFT]   |   Edit   |   Show History

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 equal
return result < 0 ? CSTR_LESS_THAN : CSTR_GREATER_THAN;
}


(I HAVEN’T TESTED THE EXAMPLE ABOVE)

Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker