tags:

views:

250

answers:

1

Please could someone explain why this does not work?

char *test = "test";
_TCHAR *szTest = CA2W(test);

And please tell me what I should be doing instead.

Instead of giving me equal text, it's giving me:

﻾﻾﻾﻾﻾﻾﻾﻾﻾﻾﻾﻾﻾﻾﻾﻾﻾﻾﻾﻾﻾﻾﻾﻾﻾﻾﻾﻾﻾﻾﻾﻾
+1  A: 

According to MSDN, that is bad. So I have used this instead:

char *test = "test";
CA2W szTest(test);

From here, we can get an LPWSTR type if we really want:

LPWSTR test = szTest.m_psz;

It also seems better to use LPWSTR instead of _TCHAR * - but I'm not sure (I think they're essentially the same thing, but could be wrong).

nbolton