您的位置:首页 > 大数据 > 人工智能

warning C4819 解决方案 warning C4819: The file contains a character that cannot be represented in the cu

2017-02-10 11:52 423 查看
原文转载于:http://blog.csdn.net/xiaoting451292510/article/details/17548957

一、

warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss

 

中文意思是:该文件包含不能在当前代码页中表示的字符,请将文件保存为Unicode格式,以防止数据丢失。

一般来说,这个警告没有什么影响。要想去掉这个警告的方法有:

 

(1)转换Code文件为Unicode格式;

(2)在Project -> Properties -> Configuration Properties -> C/C++ -> Advance 的 Disable Specific Warnings 中添加相应的警告编号:4819;

(3)或找出不符合Unicode格式的文件,然后在该文件的开始处加入下面的语句: # pragma warning (disable:4819)

(4)哪个文件出现这个警告错误,打开它, 用VS2005的查找替换功能,打开允许正则表达式选项,选择当前窗口,查找替换 \n 为 \n ,  然后,这个世界就清净了。原因:查找的 \n 是跨平台的回车,替换的 \n 却是当前代码页的回车了。

 

二、

编译VC++程序的时候出现如下提示警告:

warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss

因为只是一个warning,不影响正常编译,所以并没有引起大家多大的关注。我一开始的时候也是如此。但是后来出现的次数多了,发现这个警告和在程序Debug的时候

无法停在断点,刷刷刷就过去了根本无法进行Debug。而罪魁祸首就是这个warning,改正了这个warning就能进行Debug了。

下面讲述我是怎么消除这个警告的。

这个警告的意思是:在该文件中有一个或多个字符不是Unicode字符!要求把这个字符变成Unicode字符。

难题:在编译信息里并没有提示是哪个字符,或者是在哪一行里出现的该字符。查找起来非常的难,甚至是不可能的任务!

我在网络上找了好多资料都没有找到解决方法。因为大家都不注意这个不影响编译的警告。后来在一个国外的网站上找到了解决的方法。很简单,这个方法根本不需要知道具体是哪个字符在捣鬼!

解决方法:打开出现warning的文件,Ctrl+A全选,然后在文件菜单:file->advanced save options ,在弹出的选项中选择新的编码方式为:UNICODE codepage 1200 ,点击确定,问题就解决了。

附:

本人是在windows环境下编译chromium时遇到该问题

原因:windows系统区域设置为中文,使用DBCS(A double-byte character set) code pages。

解决方法:修改windows系统区域为英文。如图



参考文章:https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/3DV8Huz5C0M

> Warning C4819: The file contains a character that cannot be represented in the current code
page (932). Save the file in Unicode format to prevent data loss

When you see this message, you may use Chinese, Japanese or Korean Windows, and uses DBCS code page.

To avoid this warning, you need to change your Windows system code page to English or another SBCS code page. You can do this by Control Panel - Regions - Administrative - Language for non-Unicode programs.

Note: chcp 65001 in cmd.exe doesn't solve this issue.

Note: If you use Bitlocker, you may want to back up your bitlocker key before changing system code page.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐