MultiByteToWideChar

  int MultiByteToWideChar(CodePage, dwFlags, lpMultiByteStr, cchMultiByte, lpWideCharStr, cchWideChar)    
  UINT CodePage;    
  DWORD dwFlags;    
  LPSTR lpMultiByteStr;    
  int cchMultiByte;    
  LPWSTR lpWideCharStr;    
  int cchWideChar;    

The MultiByteToWideChar function is used to map a multibyte character string to its wide character counterpart.

Parameters

CodePage

Code page used to perform the conversion. If CodePage is CP_ACP, the ANSI code page is used. If CodePage is CP_OEMCP, the OEM code page is used.

dwFlags

Flags to indicate whether to translate to precomposed or composite wide characters (if a composite form exists). The default is to translate to the precomposed form (MB_PRECOMPOSED). The flags include:

Value Meaning

MB_PRECOMPOSED  
  use precomposed characters always (default)
MB_COMPOSITE  
  use composite characters always

lpMultiByteStr

Pointer to the multibyte character string to be converted. If cchMultiByte is -1, the string is assumed to be null-terminated.

cchMultiByte

Character count of string pointed to by lpMultiByteStr .

lpWideCharStr

Pointer to the memory buffer which is to receive the translated string.

cchWideChar

The character count of the memory buffer pointed to by lpWideCharStr . If cchWideChar is 0, the function returns the number of characters required to hold the translated string. lpWideCharStr is not referenced in this case.

Return Value

Success: number of wide characters returned

Failure: 0

This function sets GetLastError() with the following errors: ERROR_INSUFFICIENT_BUFFER, ERROR_INVALID_PARAMETER.

Comments

The lpMultiByteStr and lpWideCharStr pointers may NOT be the same; in this case the error ERROR_INVALID_PARAMETER is returned.