如何在 Eclipse 中支持 UTF-8 编码

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9180981/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 20:53:42  来源:igfitidea点击:

How to support UTF-8 encoding in Eclipse

eclipseencodingutf-8character-encoding

提问by Katty

How can I add UTF-8 support in eclipse? I want to add for example Russian language but eclipse won't support it. What should I do? Please guide me.

如何在 Eclipse 中添加 UTF-8 支持?我想添加例如俄语,但 eclipse 不支持它。我该怎么办?请指导我。

回答by Sajan Chandran

Try this

尝试这个

  • 1) Window > Preferences > General > Content Types, set UTF-8 as the default encoding for all content types.

  • 2) Window > Preferences > General > Workspace, set Text file encodingto Other : UTF-8

  • 1) Window > Preferences > General > Content Types, 将 UTF-8 设置为所有内容类型的默认编码。

  • 2) Window > Preferences > General > Workspace, 设置Text file encodingOther : UTF-8

回答by user3249411

Open Eclipse and do the following steps:

打开 Eclipse 并执行以下步骤:

  1. Window -> Preferences -> Expand General and click Workspace, text file encoding (near bottom) has an encoding chooser.
  2. Select "Other" radio button -> Select UTF-8 from the drop down
  3. Click Apply and OK button OR click simply OK button
  1. Window -> Preferences -> Expand General 并单击 Workspace,文本文件编码(靠近底部)有一个编码选择器。
  2. 选择“其他”单选按钮 -> 从下拉列表中选择 UTF-8
  3. 单击“应用”和“确定”按钮或单击“确定”按钮

enter image description here

在此处输入图片说明

回答by tommybee

You can set a default encoding-set whenever you run eclipse.exe.

您可以在运行 eclipse.exe 时设置默认编码集。

  1. Open eclipse.ini in your eclipse home directory Or STS.ini in case of STS(Spring Tool Suite)
  2. put the line below at the end of the file
  1. 在你的 eclipse 主目录中打开 eclipse.ini 或者在 STS(Spring Tool Suite) 的情况下打开 STS.ini
  2. 将下面的行放在文件末尾

-Dfile.encoding=UTF-8

-Dfile.encoding=UTF-8

回答by Kal

Just right click the Project -- Properties and select Resource on the left side menu.

只需右键单击 Project -- Properties 并在左侧菜单中选择 Resource。

You can now change the Text-file encoding to whatever you wish.

您现在可以将文本文件编码更改为您想要的任何内容。

回答by Divu

I tried all settings mentioned in this postto build my project successfully however that didn't work for me. At last I was able to build my project successfully with mvn -DargLine=-Dfile.encoding=UTF-8 clean insallcommand.

我尝试了这篇文章中提到的所有设置来成功构建我的项目,但这对我不起作用。最后我能够使用mvn -DargLine=-Dfile.encoding=UTF-8 clean insall命令成功构建我的项目。

回答by Abdull

You can set an explicit Java default character encoding operating system-wide by setting the environment variable JAVA_TOOL_OPTIONSwith the value -Dfile.encoding="UTF-8". Next time you start Eclipse, it should adhere to UTF-8 as the default character set.

您可以通过将环境变量设置JAVA_TOOL_OPTIONS为值来设置操作系统范围内的显式 Java 默认字符编码-Dfile.encoding="UTF-8"。下次启动 Eclipse 时,它​​应该遵循 UTF-8 作为默认字符集。

See https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/envvars002.html

请参阅https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/envvars002.html

回答by Siva Charan

You may require to install Language Packs: 3.2

您可能需要安装语言包:3.2