Multibyte string is the name for ASCII strings and wide character is the name for unicode. We can convert these wide character to multibyte or vice versa. We can do it with Win32 API or C standard library or by ATL/MFC macros. We can choose any of the mechanism depending on our application or component framework.
UNICODE String => [WideCharToMultiByte] => ASCII string
ASCII string => [MultiByteToWideChar] => UNICODE String
The MultiByteToWideChar function maps a character string to a wide-character (Unicode) string. The character string mapped by this function is not necessarily from a multibyte character set.
int MultiByteToWideChar( UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr, int cchMultiByte, LPWSTR lpWideCharStr, int cchWideChar );Parameters:
CodePage - code page
dwFlags - character-type options
lpMultiByteStr - address of string to map
cchMultiByte - number of bytes in string
lpWideCharStr - address of wide-character buffer
cchWideChar - size of buffer
The WideCharToMultiByte 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 cchMultiByte, LPCSTR lpDefaultChar, LPBOOL lpUsedDefaultChar );Parameters:
CodePage - code page
dwFlags - performance and mapping flags
lpWideCharStr - address of wide-character string
cchWideChar - number of characters in string
lpMultiByteStr - address of buffer for new string
cchMultiByte - size of buffer
lpDefaultChar - address of default for unmappable characters
lpUsedDefaultChar - address of flag set when default char. used
C STDIO library
UNICODE String => [wcstombs] => ASCII string
ASCII string => [mbstowcs] => UNICODE String
UNICODE String => [W2A/W2CA] => ASCII string
ASCII string => [A2W/A2CW] => UNICODE String
About our authors: Team EQA
MFC hides WinMain in its framework and includes source file on WinMain(). This explains how framework calls global CWinApp::Initinstance() from entry WinMain.
This is constructed during global C++ objects are constructed and is already available when Windows calls the WinMain function, which is supplied by the ...
Define a custom Window class structure, Register the class name, CreateWindow, Show windows and write message get and dispatch loop statements. Define the Window CallBack procedure and write the handlers.
DispatchMessage() is a API which indirectly triggers the Window CallBack procedure. Message structure members from this function are passed to the CallBack procedure. CallBack procedure should implement event handlers depending on the need of the application.
LPARAM and WPARAM are the two parameters in Window CallBack procedure. They signifies parameters of various events. They are used in handing individual events.
We need to write WinMain and need to follow all these in a Win32 application. However we need not to write much if we are writing an application with MFC ...
Questions index C Questions C++ Questions Win32 MFC COM/DCOM DLL Questions
Compilers & Editors
Download Visual Studio Download XCode Download Visual Studio Code Android studio install sdk Eclipse installer Best C compilers IDEs
Development system setup
Windows media creation tool MSDN subscription Ubuntu virtualbox
New updated posts
Why learn C? Draw on printer Memory leaks