|
The Locale Explorer: LCMapString
(and a custom-draw CListCtrl with multiple fonts and color)
|
|
This is an example of using LCMapString. The code in the lower edit
control is the code that would be written to retrieve the highlighted feature.
This code can be copied and pasted into an application and either used directly
or form the basis of your own code. The custom-draw CListCtrl shows the
various mappings for the LCMAP_SORTKEY option with syntax highlighting
and a fixed font for that column.
The interpretation of the display columns is as follows
- The first column is the Description, which is based on which of the data
source options is selected. For "Two specific strings", it identifies
the two strings. For "Random strings" (which isn't random, actually), it
is the hexadecimal code of the character. For "User file data" it is the
line number of the file.
- The second column, ?, gives the comparison relationship between a line and the
following line, based on the CompareString API. The value will be
one of the following:
- "<" if this line is lexically less than the next line
- ">" if this line is lexically greater than the next line
- "=" if this line is lexically equal to the next line
- "?" if CompareString returned an error code
- The third column, String, is the actual string which is being compared
- The fourth column is the Mapped String. This has several fields
which are delimited by 0x01 separator characters
- The first segment is the "Unicode sort weights", a sequence of bytes which
define the basic sort string. These are displayed in blue.
- This is followed by a 0x01 separator
- The second segment is the "diacritical weights", which are locale-specific
instructions on how to sort characters with diacritical marks. This is
displayed in green.
- This is followed by a 0x01 separator.
- The third segment is the case weights, dealing with case-sensitive or
case-insensitive comparisons. This is displayed in red.
- This is followed by a 0x01 separator.
- The fourth segment is the "all special weights". This is
displayed in magenta.
- This is followed by a 0x00 terminator
- Now this is where we have a problem. All the Microsoft documentation
suggests there are only four segments. But every example of actually
executing LCMapString produces five segments. Exactly
what this missing segment is, or what it represents, is undocumented.
There are no Knowledge Base articles suggesting anything additional. It
appears that the actual fourth segment is undocumented, and the "all special
weights" is the fifth segment.
This screen appears to resemble the CompareString
screen. This is not coincidence; the CLCMapString class is a
derived class of the CCompareString class.
The views expressed in these essays are those of the
author, and in no way represent, nor are they endorsed by, Microsoft.
Send mail to newcomer@flounder.com
with questions or comments about this web site.
Copyright © 2005 Joseph M. Newcomer/FlounderCraft Ltd.
All Rights Reserved.
Last modified:
May 14, 2011