将一个字符串映射到另一个字符串,以执行指定的与区域设置相关的转换。Maps one character string to another, performing a specified locale-dependent transformation. 此函数还可用于生成输入字符串的排序键。This function can also be used to generate a sort key for the input string.


int __crtLCMapStringW(  
   LCID    Locale,  
   DWORD   dwMapFlags,  
   LPCWSTR lpSrcStr,  
   int     cchSrc,  
   LPWSTR  lpDestStr,  
   int     cchDest)  


区域设置标识符。Locale identifier. 区域设置为字符串映射或排序键生成提供上下文。The locale provides a context for the string mapping or sort key generation. 应用程序可使用 MAKELCID 宏创建区域设置标识符。An application can use the MAKELCID macro to create a locale identifier.

在字符串或排序键生成期间要使用的转换的类型。The type of transformation to be used during string mapping or sort key generation.

指向函数映射或用于排序键生成的源字符串的指针。Pointer to a source string that the function maps or uses for sort key generation. 假定此参数为 Unicode 字符串。This parameter is assumed to be a Unicode string.

lpSrcStr 参数指向的字符串的大小(以字符为单位)。Size, in characters, of the string pointed to by the lpSrcStr parameter. 此计数可包含 NULL 终止符,也可不包含它。This count can include the NULL terminator, or not include it.

cchSrc 值 -1 指定由 lpSrcStr 指向的字符串是以 null 结尾的。A cchSrc value of -1 specifies that the string pointed to by lpSrcStr is null-terminated. 如果是这种情况而且此函数在使用时采用了字符串映射模式,则此函数会自己计算字符串的长度,并以 null 终止存储在 *lpDestStr中的映射字符串。If this is the case, and this function is being used in its string-mapping mode, the function calculates the string's length itself, and null-terminates the mapped string stored into *lpDestStr.

指向函数将映射字符串或排序键存储到其中的缓冲区的长指针。Long pointer to a buffer into which the function stores the mapped string or sort key.

lpDestStr指向的缓冲区的大小(以字符为单位)。Size, in characters, of the buffer pointed to by lpDestStr.

返回值Return Value

如果 cchDest 的值不为零,则写入到缓冲区的字符数(如果指定了 LCMAP_SORTKEY ,则为字节数)表示成功。If the value of cchDest is nonzero, the number of characters, or bytes if LCMAP_SORTKEY is specified, written to the buffer indicates success. 此计数包括 NULL 终止符的空间。This count includes room for a NULL terminator.

如果 cchDest 值为零,则接收转换的字符串或排序键所需的缓冲区大小(以字符为单位,如果指定了 LCMAP_SORTKEY ,则以字节为单位)表示成功。If the value of cchDest is zero, the size of the buffer in characters, or bytes if LCMAP_SORTKEY is specified, required to receive the translated string or sort key indicates success. 此大小包括 NULL 终止符的空间。This size includes room for a NULL terminator.

零表示失败。Zero indicates failure. 若要获得扩展的错误信息,请调用 GetLastError 函数。To get extended error information, call the GetLastError function.


如果 cchSrc 大于零且 lpSrcStr 是一个以 null 结尾的字符串,则 __crtLCMapStringWcchSrc 设置为字符串的长度。If cchSrc is greater than zero and lpSrcStr is a null-terminated string, __crtLCMapStringW sets cchSrc to the length of the string. 然后, __crtLCMapStringW 使用指定的参数调用 LCMapString 函数的宽字符串 (Unicode) 版本。Then __crtLCMapStringW calls the wide string (Unicode) version of the LCMapString function with the specified parameters. 有关此函数的参数和返回值的详细信息,请参阅 LCMapString MSDN 库 中的函数。For more information about the parameters and return value of this function, see the LCMapString function at MSDN Library.


例程Routine 必需的标头Required header
__crtLCMapStringW__crtLCMapStringW awint.hawint.h