Re: C++ type conversion question



"Alex Smotritsky" <AlexSmotritsky@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message news:1EDF6FE9-DD4C-4156-BF1A-80FC3B48550C@xxxxxxxxxxxxx
I have a TCHAR* referencing a string and I want to get that data into
a WCHAR []

How do I do that?

A TCHAR might already be a WCHAR, depending on whether or not UNICODE is
defined. So first figure out what your TCHAR actually is.

If TCHAR is a WCHAR, then you can use wcscpy to copy the string to the WCHAR
array. If TCHAR is a char (or, equivalently, CHAR), then you should use
MultiByteToWideChar to make the conversion.


--
John Carson


.



Relevant Pages

  • Re: Window types
    ... typedef WCHAR TCHAR, * PTCHAR; ... typedef char TCHAR, * PTCHAR; ... Under a Unicode build, ... If the only text your app needs to deal with can be handled with ASCII ...
    (microsoft.public.vc.language)
  • Re: TCHAR Copying
    ... You said you have a CString, and a library that takes a TCHAR*. ... It wants a const WCHAR* ... It is MUCH more difficult if you want char*, because although the same techniques as shown ... Debug, WCHAR, DLL, 32-bit ...
    (microsoft.public.vc.mfc)
  • Re: TCHAR and buffer overflows
    ... This would be a problem if you hadn't defined UNICODE in your build. ... unsigned char *_mbsncpy(unsigned char *strDest, ... >> macro WCHAR was introduced to switch between ascii and unicode chars as ... > I think you mean TCHAR. ...
    (comp.security.misc)
  • Re: TCHAR and buffer overflows
    ... This would be a problem if you hadn't defined UNICODE in your build. ... unsigned char *_mbsncpy(unsigned char *strDest, ... >> macro WCHAR was introduced to switch between ascii and unicode chars as ... > I think you mean TCHAR. ...
    (comp.os.ms-windows.nt.admin.security)
  • Re: VC2005 Pro: IDE (Compiler ?) cant find Stdafx.h
    ... For new code I would obviously use UNICODE but for existing stuff ... > Use Multi-Byte Character Set ... > If you use TCHAR etc., and want your code to run on another platform, then ... > typedef char TCHAR; ...
    (microsoft.public.vc.language)

Loading