المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Converting ANSI to UNICODE



C++ Programming
08-05-2009, 12:06 PM
Dear All,

I am having problem in converting ANSI to UNICODE but my code is not giving the desired result. Please have a look at the below code and advice me. When I compare the both strings, the strings are not equal after conversion. Please help me. Many thanks in advance.


char szData[2] ;
szData[0] = '?';
szData[1] = 0;
wchar_t wszData1[] = L"?";
wchar_t wszData2[2];
MultiByteToWideChar(CP_ACP, 0, szData, -1, wszData2, sizeof(wszData2) / sizeof wchar_t));
if (wcscmp(wszData1, wszData2) == 0)
MessageBox("Strings are equal!");
else
MessageBox("Strings are not equal.");