解决vc2008 utf8中文字符串报错 C2001常量中有换行符

来源:互联网 发布:淘宝扶持政策 编辑:程序博客网 时间:2024/05/16 19:48

vs2008需要升级到sp1,然后打补丁 VS90SP1-KB980263-x86.exe

c源文件以utf8 without bom保存,并添加


#ifdef _MSC_VER
#pragma execution_character_set("utf-8")
#endif


编译器即可正确识别utf8字符。

不会再报错说

 C2001常量中有换行符


还可以给编译器添加编译参数

 /FI preinclude.h 
创建上述.h文件,内容为上述pragma语句即可让整个工程默认utf8字符串


参考

http://blog.csdn.net/qq_36613650/article/details/69397597 
https://stackoverflow.com/questions/23607830/does-vc-have-a-compile-option-like-fexec-charset-in-gcc-to-set-the-execution 

阅读全文
0 0
原创粉丝点击