_CrtDbgReport: String too long or IO Error

_CrtDbgReport: String too long or IO Error

 

wprintf_s不能正常出中文的解决

使用如下方法wprintf_s出中文往往出现带?的乱:

wprintf_s(L"%s",(LPCWSTR)cmdLineArr[1]);

 解决方案:包含文件locale.h,并在程序开始setlocale(LC_ALL, "chs");

这样wprintf_s便能正常打印出中文字符串了:

 //指定当前程序的编码为简体中文,这样才能用wprintf正确出中文

#include <locale.h>
setlocale(LC_ALL, "chs");

样对TRACE(_T("第一个:%s,第二个:%s"),str1,str2);,如果运行出信息:“_CrtDbgReport: String too long or IO Error”。亦可用上述方法解决。

 

TRACE在定义时就已考unicode,所以不需要加_T

可以采用OutputDebugString()来代替TRACE,它自采用UNICODE和非UNICODE

 

Microsoft Visual Studio Feedback上的反馈

http://connect.microsoft.com/VisualStudio/feedback/details/425215/bug-with-trace-and-crtdbgreport

There is a bug with TRACE and _CrtDbgReport when working with the wide string.
_CrtDbgReport can't handle the wide string correctly when the wide string contains non-ascii characters.

貌似在Beta 2 of Visual Studio 2010.修正了该bug

转载于:https://www.cnblogs.com/BeyondTechnology/archive/2011/01/09/1931533.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值