Microsoft KB Archive/221213

{|
 * width="100%"|

DOC: Documentation Error Using LCMapString to Convert Between Simplified and Traditional Chinese

 * }

Q221213

-

The information in this article applies to:


 * Microsoft Windows NT Server version 4.0
 * Microsoft Windows NT Workstation version 4.0
 * Microsoft Windows 2000 Advanced Server
 * Microsoft Windows 2000 Server
 * Microsoft Windows 2000 Professional

-

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 
 * 1) include 

/////////////////////////////////////////////////////// void main(void) {

TCHAR Buf1[16] = {0x96FB, 0x8996, 0x0000}; TCHAR Buf2[16]; BYTE Buf1[16] = {0xEB, 0x8A, 0xD2, 0x95, 0x00}; BYTE Buf2[16];
 * 1) ifdef UNICODE
 * 1) else
 * 1) endif

if(!LCMapString(0x0804, // Locale id of simplified Chinese. LCMAP_SIMPLIFIED_CHINESE, Buf1, -1, Buf2, 16)) {       printf("LCMapString failed with Error# = %d", GetLastError); }   else {       printf("\nLCMAP_SIMPLIFIED_CHINESE:\tU+%04x U+%04x -> U+%04x U+%04x\n",                Buf1[0], Buf1[1],                Buf2[0], Buf2[1]); 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]);
 * 1) ifdef UNICODE
 * 1) else
 * 1) endif

if(!LCMapString(0x0804, // Locale id of simplified Chinese. LCMAP_TRADITIONAL_CHINESE, Buf2, -1, Buf1, 16)) {           printf("LCMapString failed with Error# = %d", GetLastError); }       else {           printf("\nLCMAP_TRADITIONAL_CHINESE:\tU+%04x U+%04x -> U+%04x U+%04x\n",                    Buf2[0], Buf2[1],                    Buf1[0], Buf1[1]); 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]); }   } } Additional query words:
 * 1) ifdef UNICODE
 * 1) else
 * 1) endif

Keywords : kbdocfix kbdocerr kbNLS kbOSWinNT400 kbOSWin2000 kbSDKPlatform kbUnicode kbLocalization kbDBCS

Issue type : kbbug

Technology : kbWinNTsearch kbWinNTWsearch kbWinNTW400 kbWinNTW400search kbWinNT400xsearch kbwin2000AdvServ kbwin2000AdvServSearch kbwin2000Serv kbWinNTSsearch kbWinNTS400xsearch kbWinNTS400 kbwin2000ServSearch kbwin2000Search kbwin2000ProSearch kbwin2000Pro kbWinAdvServSearch