DOC: Documentation Error Using LCMapString to Convert Between Simplified and Traditional Chinese
ID: Q221213
|
The information in this article applies to:
-
Microsoft Windows NT 4.0
-
Microsoft Windows 2000
SUMMARY
The LCMapString function maps one character string to another, performing a specified locale-dependent transformation. The second parameter of this function call is a flag that indicates the type of transformation to be used during string mapping.
The MSDN library, January 1999 and previous editions, incorrectly states that the LCMAP_TRADITIONAL_CHINESE flag maps traditional Chinese characters to simplified Chinese characters, and the flag LCMAP_SIMPLIFIED_CHINESE maps simplified Chinese characters to traditional Chinese characters.
In fact, the reverse is true, that is: LCMAP_TRADITIONAL_CHINESE maps simplified Chinese characters to traditional Chinese characters, and LCMAP_SIMPLIFIED_CHINESE maps traditional Chinese characters to simplified Chinese characters.
The documentation is also inaccurate in implying that the flags are valid on Windows9x; instead, they can be used only on Windows NT 4.0 and Windows 2000.
MORE INFORMATION
The LCMapString function is particularly useful for the developer who wants to support both simplified and traditional Chinese Windows NT with minimum effort. Here is a small sample working under both the DBCS build and the Unicode build. The two Chinese characters in the sample are "television." The code point of these characters in traditional Chinese format are given either in DBCS or Unicode, and they are correctly converted to simplified format and then back to traditional format:
Sample Code
#include <stdio.h>
#include <windows.h>
///////////////////////////////////////////////////////
void main(void)
{
#ifdef UNICODE
TCHAR Buf1[16] = {0x96FB, 0x8996, 0x0000};
TCHAR Buf2[16];
#else
BYTE Buf1[16] = {0xEB, 0x8A, 0xD2, 0x95, 0x00};
BYTE Buf2[16];
#endif
if(!LCMapString(0x0804, // Locale id of simplified Chinese.
LCMAP_SIMPLIFIED_CHINESE,
Buf1, -1,
Buf2, 16))
{
printf("LCMapString failed with Error# = %d", GetLastError());
}
else
{
#ifdef UNICODE
printf("\nLCMAP_SIMPLIFIED_CHINESE:\tU+%04x U+%04x -> U+%04x U+%04x\n",
Buf1[0], Buf1[1],
Buf2[0], Buf2[1]);
#else
printf("\nLCMAP_SIMPLIFIED_CHINESE:\t"
"0x%02x%02x 0x%02x%02x -> 0x%02x%02x 0x%02x%02x\n",
Buf1[0], Buf1[1], Buf1[2], Buf1[3],
Buf2[0], Buf2[1], Buf2[2], Buf2[3]);
#endif
if(!LCMapString(0x0804, // Locale id of simplified Chinese.
LCMAP_TRADITIONAL_CHINESE,
Buf2, -1,
Buf1, 16))
{
printf("LCMapString failed with Error# = %d", GetLastError());
}
else
{
#ifdef UNICODE
printf("\nLCMAP_TRADITIONAL_CHINESE:\tU+%04x U+%04x -> U+%04x U+%04x\n",
Buf2[0], Buf2[1],
Buf1[0], Buf1[1]);
#else
printf("\nLCMAP_TRADITIONAL_CHINESE:\t"
"0x%02x%02x 0x%02x%02x -> 0x%02x%02x 0x%02x%02x\n",
Buf2[0], Buf2[1], Buf2[2], Buf2[3],
Buf1[0], Buf1[1], Buf1[2], Buf1[3]);
#endif
}
}
}
Additional query words:
Keywords : kbdocfix kbdocerr kbNLS kbNTOS400 kbWinOS2000 kbSDKPlatform kbUnicode kbLocalization kbDBCS
Version : WINDOWS:; winnt:4.0
Platform : WINDOWS winnt
Issue type : kbbug