开发者

How am I using CA2W incorrectly?

开发者 https://www.devze.com 2022-12-09 20:01 出处:网络
Please could someone explain why this does not work? c开发者_StackOverflowhar *test = \"test\"; _TCHAR *szTest = CA2W(test);

Please could someone explain why this does not work?

c开发者_StackOverflowhar *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:

﻾﻾﻾﻾﻾﻾﻾﻾﻾﻾﻾﻾﻾﻾﻾﻾﻾﻾﻾﻾﻾﻾﻾﻾﻾﻾﻾﻾﻾﻾﻾﻾


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).

0

精彩评论

暂无评论...
验证码 换一张
取 消