mfc如何将unicode码转换为asci

2025-03-04 02:23:47
推荐回答(1个)
回答1:

WideCharToMultiByte

wchar_t wText[20] = {L"宽字符转换实例!OK!"};
  DWORD dwNum = WideCharToMultiByte(CP_OEMCP,NULL,wText,-1,NULL,0,NULL,FALSE);
  char *psText;
  psText = new char[dwNum];
  if(!psText)
  {
   delete []psText;
  }
  WideCharToMultiByte (CP_OEMCP,NULL,wText,-1,psText,dwNum,NULL,FALSE);
  delete []psText;