warning c4819 in Visual Studio C++ 2013 express - utf8 files without bom

后端 未结 4 1116
慢半拍i
慢半拍i 2021-01-03 03:39

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 trea

4条回答
  •  攒了一身酷
    2021-01-03 03:49

    How should the compiler guess which encoding you intend the file to be interpreted with? That said, there are a few options:

    • Why not simply add a BOM? It's a pretty good way to mark a UTF-8 file, as it is very unlikely to be misinterpreted.
    • Other than that, I believe you can use a #pragma to tell MSC about the encoding, although I never used this myself.
    • Lastly, not using anything outside the basic character set is also an option which is slightly outdated in our world but still works reliable.

提交回复
热议问题