- 注册时间
 - 2021-4-16
 
- 最后登录
 - 2025-3-14
 
- 在线时间
 - 6 小时
 
 
 
 
 
编程入门 
  
	- 龙马币
 - 470 
 
 
 
 
 | 
 
 
C++ Ansi转Unicode - Unicode转Ansi源码 
 
ANSI转unicode 
-  //ANSI转unicode
 
 - wchar_t* AnsiToUnicode(char *str)
 
 - {
 
 -         DWORD dwNum = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0);
 
 -         wchar_t *pwText;
 
 -         pwText = new wchar_t[dwNum];
 
 -         if(!pwText)
 
 -         {
 
 -                 delete []pwText;
 
 -         }
 
 -         MultiByteToWideChar (CP_ACP, 0, str, -1, pwText, dwNum);
 
 -         return pwText;
 
 - }wchar_t *strUnicode = AnsiToUnicode(str);
 
 - OutputDebugStringW(strUnicode);
 
  复制代码 
 
Unicode转ansi 
- //Unicode转ansi
 
 - wchar_t wText[20] = {L"宽字符转换实例!"};
 
 -  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;
 
  复制代码 
 
  |   
 
 
 
 |