各位大侠,怎样将char *转换为wchar_t*,我用下面程序转换后发现汉字成了乱码?
void __fastcall TForm1::BitBtn1Click(TObject *Sender)
{
char *CStr="您好!good";
size_t len=strlen(CStr)+1;
wchar_t *WStr;
WStr=(wchar_t*)malloc(len*sizeof(wchar_t));
mbstowcs(WStr,CStr,len);
Form1->Caption=WStr;
}
才接触C++Builder,请大家帮助,谢谢!
[解决办法]
char *CStr="您好!good";
wchar_t *WStr = new wchar_t[50];
wcspcpy(WStr, WideString(CStr).c_bstr());
Form1->Caption=WStr;