问题描述
在 Visual Studio C++ 2013 express 中,除非 utf8 编码的文件具有 BOM 标记,否则编译器无法理解正在编译的文件是 UTF8 编码并将其视为本机编码.但是代码编辑器没有这个问题.
In visual studio C++ 2013 express it seems that unless utf8-encoded file has BOM mark, compiler fails to understand that the file being compiled is in UTF8 encoding and treats it as being in native encoding. Code editor, however, does not have this problem.
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
是否有针对此行为的修复方法?我记得这是所有 Visual Studio 版本中的常见问题,但我不记得曾经看到过修复.我无法准确地为每个不属于我的文件添加 bom 标记,尤其是在代码存储库中维护源代码的情况下.
Is there a fix for this behavior? I remember this being common problem in all visual studio versions, but I don't remember ever seeing a fix. I can't exactly keep adding bom marks to every file that is not mine, especially if source is maintained in code repository.
推荐答案
到目前为止我还没有遇到任何问题的解决方案.
To the date I have not encountered any solution to the problem.
如果存在针对此行为的修复程序,则显然这是保密的.
If a fix for this behavior exists, apparently it is well guarded secret.
这篇关于Visual Studio C++ 2013 express 中的警告 c4819 - 没有 bom 的 utf8 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!