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



The information in this article applies to:

  • Microsoft Windows 2000 Server
  • Microsoft Windows 2000 Advanced Server
  • Microsoft Windows 2000 Professional
  • Microsoft Windows NT Server 4.0
  • Microsoft Windows NT Workstation 4.0

This article was previously published under Q221213

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
        }
    }
}
				

Modification Type:MinorLast Reviewed:2/11/2004
Keywords:kbDSXGlobal2003Swept kbbug kbDBCS kbdocerr kbdocfix kbLocalization kbNLS kbUnicode KB221213