Important: |
---|
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
This function maps a wide-character string to a new character string. The new character string is not necessarily from a multibyte character set.
int WideCharToMultiByte( UINT CodePage , DWORD dwFlags , LPCWSTR lpWideCharStr , int cchWideChar , LPSTR lpMultiByteStr , int cbMultiByte , LPCSTR lpDefaultChar , LPBOOL lpUsedDefaultChar );
Parameters
Value | Description |
---|---|
CP_ACP | ANSI code page |
CP_MACCP | Not supported |
CP_OEMCP | OEM code page |
CP_SYMBOL | Not supported |
CP_THREAD_ACP | Not supported |
Value | Description |
---|---|
WC_COMPOSITECHECK | Convert composite characters to precomposed characters. |
WC_DISCARDNS | Discard nonspacing characters during conversion. |
WC_SEPCHARS | Generate separate characters during conversion. This is the default conversion behavior. |
WC_DEFAULTCHAR | Replace exceptions with the default character during conversion. |
When WC_COMPOSITECHECK is specified, the function converts composite characters to precomposed characters. A composite character consists of a base character and a nonspacing character, each having different character values. A precomposed character has a single character value for a base/nonspacing character combination. In the character �, the eis the base character, and the accent grave mark is the nonspacing character.
When an application specifies WC_COMPOSITECHECK, it can use the last three flags in this list (WC_DISCARDNS, WC_SEPCHARS, and WC_DEFAULTCHAR) to customize the conversion to precomposed characters. These flags determine the function's behavior when there is no precomposed mapping for a base/nonspace character combination in a wide-character string. These last three flags can only be used if the WC_COMPOSITECHECK flag is set.
The function's default behavior is to generate separate characters (WC_SEPCHARS) for unmapped composite characters.
Return Values
If cbMultiByteis nonzero, the number of bytes written to the buffer pointed to by lpMultiByteStrindicates success. If cbMultiByteis zero, the required size, in bytes, for a buffer that can receive the translated string indicates success. Zero indicates failure. To get extended error information, call GetLastError. Possible values for GetLastErrorinclude the following:
Remarks
The lpMultiByteStrand lpWideCharStrpointers must not be the same. If they are the same, the function fails, and GetLastErrorreturns ERROR_INVALID_PARAMETER.
An application can use the lpDefaultCharparameter to change the default character used for the conversion.
As noted earlier, the WideCharToMultiBytefunction operates most efficiently when both lpDefaultCharand lpUsedDefaultCharare NULL. The following table shows the behavior of WideCharToMultiBytefor the four combinations of lpDefaultCharand lpUsedDefaultChar:
lpDefaultChar | lpUsedDefaultChar | Result |
---|---|---|
NULL | NULL | No default checking. This is the most efficient, quick way to use this function. |
non-NULL | NULL | Uses the specified default character, but does not set lpUsedDefaultChar. |
NULL | non-NULL | Uses the system default character and sets lpUsedDefaultCharif necessary. |
non-NULL | non-NULL | Uses the specified default character and sets lpUsedDefaultCharif necessary. |
Requirements
Runs on | Versions | Defined in | Include | Link to |
---|---|---|---|---|
Windows CE OS | 1.01 and later | Winnls.h |
Note This API is part of the complete Windows CE OS package as provided by Microsoft. The functionality of a particular platform is determined by the original equipment manufacturer (OEM) and some devices may not support this API.
See Also
GetLastError, MultiByteToWideChar