`
xiongpan0807
  • 浏览: 15832 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
最近访客 更多访客>>
社区版块
存档分类
最新评论

[字符编码]Invalid byte 1 of 1-byte UTF-8 sequence终极解决方案

    博客分类:
  • xml
阅读更多

今天在eclipse中编写pom.xml文件时,注释中的中文被eclipse识别到错误:Invalid byte 1 of 1-byte UTF-8 sequence,曾多次遇到该问题,问题的根源是:

The cause of this is a file that is not UTF-8 is being parsed as UTF-8. It is likely that the parser is encountering a byte value in the range FE-FF. These values are invalid in the UTF-8 encoding.

但这次很诡异,我使用notepad++将pom.xml的编码保存为“UTF-8无BOM”形式,pom.xml文件内的encoding属性设 置为“UTF-8”,问题依旧啊,郁闷了,难道上述的理论有问题?还是eclipse的bug呢?在网上看了半天,基本都是这么说的。

第一,可以直接在XML文件中更改UTF-8为GBK或GB2312

         <?xml   version="1.0"   encoding="GB2312"?>

第二,可以在Eclipse中更改,在 eclipse 的功能表 [Project]→[Properties],點選 [Resources],在右邊的「Text file encoding」,把原來是系統預設的編碼,改為 「UTF-8」。

第一种方案可行,属于逃避的方法,放弃!第二种也不是解决我这种问题的,继续网上搜索惊奇的发现,原来解决方案是这样的:

把xml的encoding属性值UTF-8改为UTF8,我操,太伤蛋了

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics