---
title: "【无奈】Invalid byte 1 of 1-byte UTF-8 sequence解决方案"
author: "shaomeng95"
date: "2011-12-30T20:55:41Z"
tags: []
categories: ["Web前端"]
slug: "invalid-byte-1-of-1-byte-utf-8-sequence"
draft: false
lastmod: "2011-12-30T20:57:39Z"
id: 1330786
url: "https://shaomeng95.iteye.com/blog/1330786"
---

今天在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](http://en.wikipedia.org/wiki/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
> 
>          &lt;?xml   version="1.0"   encoding="GB2312"?&gt;
> 
> 第二，可以在Eclipse中更改，在 eclipse 的功能表 \[Project]→\[Properties]，點選 \[Resources]，
> 
>          在右邊的「Text file encoding」，把原來是系統預設的編碼，改為 「UTF-8」。

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

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

 

**有知道为什么会这样的兄弟，请赶紧告诉偶吧，求求你了！**