简体   繁体   English

Eclipse,错误:无法映射的GBK字符

[英]Eclipse, error: unmappable character for encoding GBK

I have a Java project in Linux with Eclipse as IDE. 我在Linux中有一个Java项目, Eclipse是IDE。 I just pull the project from SVN onto my windows 7 machine. 我只是将项目从SVN拉到Windows 7计算机上。 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. 我注意到Eclipse在Linux(Fedora 20)中使用utf-8,在Windows中使用GBK。 My questions are the following: 我的问题如下:

  1. should I use the same encoding in both systems? 我应该在两个系统中使用相同的编码吗? if yes, utf-8 or GBK? 如果是,是utf-8还是GBK?
  2. how to make my code compilable in windows by a batch action? 如何通过批处理操作在Windows中编译我的代码? 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. 当我使用ant进行构建时,出现了相同的错误。 After I changed my windows eclipse default encoding to utf-8, I still got the same error. 将Windows eclipse的默认编码更改为utf-8后,仍然出现相同的错误。 I may need conversion? 我可能需要转换吗?

EDIT2: EDIT2:

After the change of Eclipse it works now. 更改Eclipse之后,它现在可以工作。 But the ant still give me the same error. 但是蚂蚁仍然给我同样的错误。

EDIT3: EDIT3:

for the ant issue, found the solution here: "unmappable character for encoding" warning in Java 对于蚂蚁问题,请在此处找到解决方案: 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. 由于您是在Linux系统上创建文件的,因此文件大概是使用UTF-8编码的,因此您需要将Windows Eclipse设置为也使用UTF-8。

You can set the default encoding in Eclipse in the 'Text file encoding' entry on the 'Windows > Preferences > General > Workspace' preference page. 您可以在Eclipse的“ Windows>首选项>常规>工作区”首选项页面上的“文本文件编码”条目中设置默认编码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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