http://www.pczpg.com/html/bianchengkaifa/VC_VC__/20091204/24599.html

 

建立MFC应用程序,支持Unicode库
CString str1=(_T("1哈哈"));
CString str2=(_T("2哈哈"));
TRACE(_T("第一个=%s,第二个=%s"),str1,str2);
TRACE只能在DEBUG下才能显示效果
调试

TRACE主要用来了解代码执行到了哪里.在 Unicode下会出现String too long or IO Error打印不出字符串.
将工程的字符集设置为使用多字节字符集,就可以在OUTPUT窗口中看到答应的信息.
或者将区域设置成中文
代码如下

#include <locale.h>


char* old_locale = _strdup( setlocale(LC_CTYPE,NULL) );
setlocale( LC_CTYPE, "chs" );
CString str1=(_T("1哈哈"));
CString str2=(_T("2哈哈"));
TRACE(_T("第一个=%s,第二个=%s"),str1,str2);
setlocale( LC_CTYPE, old_locale);
free(old_locale);
在OUTPUT窗口或者运行Dbgview程序可以看到打印出信息

相关文章:

  • 2022-12-23
  • 2021-11-11
  • 2022-12-23
  • 2022-12-23
  • 2022-01-01
  • 2022-12-23
  • 2022-12-23
  • 2022-01-24
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-30
  • 2022-12-23
  • 2021-07-21
相关资源
相似解决方案