0

I know Java uses UTF-16 internally and expects .properties files to be in ISO-8859-1 by default.

I'm currently working on a project that was written in Eclipse, whose default encoding on our systems is cp-1252. I'm thinking utf-8 would be a much more sensible option, going forward.

However, given the scale of the project (it's split up into modules and uses libraries from all over the place), I can't just batch-convert all source code files in one go.

Will Java have a problem with some files in a project being in one encoding and some in another? (Clearly, having entire libraries written in encodings that are different from one another doesn't seem to be a problem - probably because they are all UTF-16 once compiled, anyway.)

Would Eclipse be able to handle that (i.e. different encodings per file) correctly?

4

1 回答 1

1

是的你可以。

您可以选择用于整个 Eclipse 项目的默认编码:

  • 右键单击一个项目
  • resource部分
  • Text file encoding区域,检查Other并在组合中选择UTF-8(或您想要的)

您还可以更改特定文件的编码:

  • 右键单击文件
  • resource部分
  • Text file encoding区域,检查Other并在组合中选择UTF-8(或您想要的)

首选项存储在.settings项目的隐藏文件夹中。文件编码首选项存储在.settings/org.eclipse.core.resources.prefs.

这些偏好可以使用您最喜欢的源代码控制提交并与其他开发人员共享。

于 2014-10-12T17:25:39.847 回答