Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i suppport both Unicode and Multi-Byte Character Set in my code?

i must say im new to win32 c++ programming so i face a problem that
some code compile in Multi-Byte Character Set and not in Unicode Character Set.
how can my code support both ?
for example this NOT compiles in Multi-byte only in Unicode and the commented vector only in MultiByte:

 //vector<char> str2(FullPathToExe.begin(), FullPathToExe.end());
 vector<wchar_t> str2(FullPathToExe.begin(), FullPathToExe.end());

    str2.push_back('\0');
    if (!CreateProcess(NULL,
                     &str2[0],
                    NULL,
                    NULL,
                    TRUE,
                    0,
                    NULL,
                    NULL,
                    &si,
                    &pi))
like image 269
user63898 Avatar asked Dec 07 '25 12:12

user63898


1 Answers

Use TCHAR as the character type (e.g. std::vector<TCHAR>), which is:

A WCHAR if UNICODE is defined, a CHAR otherwise.

This type is declared in WinNT.h as follows:

#ifdef UNICODE
   typedef WCHAR TCHAR;
#else
   typedef char TCHAR;
#endif
like image 173
Georg Fritzsche Avatar answered Dec 10 '25 01:12

Georg Fritzsche