参考:https://www.cnblogs.com/kuliuheng/archive/2013/10/30/3397796.html
出现如下错误:

原因是文件编码格式是“UTF-8”(不是微软自家的UTF-8 with BOM)因此对基数个数的中文会报上述错误
备注:UTF-8与UTF-8(BOM)区别
解决方案:
(1)全部用英文编码,不要用中文
(2)偶数中文 或 结尾加英文的符号,如"."
(3)将文件编码进行一个手动(如记事本)转换,改成UTF-8格式
至于该问题的详细原因,参考一位网友的分析说明(引用:http://www.cnblogs.com/cocos2d-x/archive/2012/02/26/2368873.html):
有个叫wva的人遇到过类似问题,他向微软提交了此bug
http://connect.microsoft.com/VisualStudio/feedback/details/341454/compile-error-with-source-file-containing-utf8-strings-in-cjk-system-locale
根据Visual C++ Compiler Team员工的解释:
The compiler when faced with a source file that does not have a BOM the compiler reads ahead a certain distance into the file to see if it can detect any Unicode characters - it specifically looks for UTF-16 and UTF-16BE - if it doesn't find either then it assumes that it has MBCS. I suspect that in this case that in this case it falls back to MBCS and this is what is causing the problem.
看见了吧,对于那些没有BOM的文件设计就是这样的。从语气上看,他们编译器小组也不打算修改设计。所以呢,在VC上使用“无签名的UTF-8”编码的文件,你就是在抱着一颗不定时炸弹玩耍。因为你永远都不敢确定哪些词能通过编译,哪些不能!
如果要硬编码字符串,即便是字符编码转换也不一定能帮不上你。一旦你为此增加了字符编码转换的代码,那么也意味着可移植性降低了。因为这从根本上是编译器决定的。
本文探讨了在使用UTF-8编码的源文件中遇到的编译错误问题,特别是在没有BOM标记的情况下,编译器可能无法正确处理中文字符,导致错误。文章提供了几种解决方案,包括使用英文编码、调整中文字符数量或位置,以及更改文件编码格式。
&spm=1001.2101.3001.5002&articleId=105404375&d=1&t=3&u=b8e6c80aafdf4b88a358cde7e2750216)
4540

被折叠的 条评论
为什么被折叠?



