TCHAR* to WCHAR*

Started by
3 comments, last by Newfound Ajarn 20 years, 5 months ago
I'm using c++ and I need to cast a value in a TCHAR* (char*) to a WCHAR*. The normal typecast ((WCHAR*)strtchar) works when compiling, but doesn't work on runtime. Could someone please tell me how I can do this? Thank you in advance. [edited by - Newfound Ajarn on November 11, 2003 1:51:43 AM]
VLAjarn: Cause it (linux) NEVER crashesMrPr0Grmer: lol ur wrongMrPr0Grmer: RedHat crashesVLAjarn: I'm saying good builds of linux
Advertisement
Are you sure you want to cast the pointer? Or do you really want to convert the string?
.
Convert the string.
VLAjarn: Cause it (linux) NEVER crashesMrPr0Grmer: lol ur wrongMrPr0Grmer: RedHat crashesVLAjarn: I'm saying good builds of linux
TCHAR compiles differently depending on whether you have UNICODE defined for your project. If UNICODE is not defined, a TCHAR is the same as a char. If UNICODE is defined, then a TCHAR is a wchar_t.

Having said that, the conversion functions you are probably looking for are mbstowcs() and wcstombs() (MBS stands for ''multi-byte string'' and wcs is ''wide character string''). Look on msdn.microsoft.com for the exact arguments.
Thank you.
VLAjarn: Cause it (linux) NEVER crashesMrPr0Grmer: lol ur wrongMrPr0Grmer: RedHat crashesVLAjarn: I'm saying good builds of linux

This topic is closed to new replies.

Advertisement