# include & lt string & gt
# include & ltwindows.h & gt
# include & ltwinnls.h & gt
Use namespace std
int main()
{
STD::string szDst;
wchar _ t wText[20]= { L " China China " };
DWORD dwNum = WideCharToMultiByte(CP _ OEMCP,NULL,wText,- 1,NULL,0,NULL,FALSE);
char * psText
psText = new char[dw num];
WideCharToMultiByte (CP_OEMCP,NULL,wText,- 1,psText,dwNum,NULL,FALSE);
szDst = psText
//Delete temporary variables
Delete [] pstext;
//output
cout & lt& ltszDst & lt& ltendl
Returns 0;
}
I also changed it through online reference. If there is no Unicode but only Ascii, you can directly use loops to force char conversion on a per-character basis.