简体   繁体   中英

Eclipse, error: unmappable character for encoding GBK

I have a Java project in Linux with Eclipse as IDE. I just pull the project from SVN onto my windows 7 machine. I was surprised that I got lots of this:

error: unmappable character for encoding GBK 

Some of the characters in the comments are not readable anymore. I corrected these character but I still got above error even these comments are readable again.

I notice Eclipse use utf-8 in my Linux (Fedora 20) and GBK in my Windows. My questions are the following:

  1. should I use the same encoding in both systems? if yes, utf-8 or GBK?
  2. how to make my code compilable in windows by a batch action? There are many files and I don't want to do it one by one.
  3. how avoid this happen again in the future?

EDIT:

I got the same error when I use ant to build. After I changed my windows eclipse default encoding to utf-8, I still got the same error. I may need conversion?

EDIT2:

After the change of Eclipse it works now. But the ant still give me the same error.

EDIT3:

for the ant issue, found the solution here: "unmappable character for encoding" warning in Java

Yes it is vital that you use the same encoding for the files on all platforms.

Since you created the files on your Linux system the files are presumably encoded using UTF-8 so you need to set your Windows Eclipse to use UTF-8 also.

You can set the default encoding in Eclipse in the 'Text file encoding' entry on the 'Windows > Preferences > General > Workspace' preference page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM