如何在 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
How to support UTF-8 encoding in Eclipse
提问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
, setText file encoding
toOther : UTF-8
1)
Window > Preferences > General > Content Types
, 将 UTF-8 设置为所有内容类型的默认编码。2)
Window > Preferences > General > Workspace
, 设置Text file encoding
为Other : UTF-8
回答by user3249411
Open Eclipse and do the following steps:
打开 Eclipse 并执行以下步骤:
- Window -> Preferences -> Expand General and click Workspace, text file encoding (near bottom) has an encoding chooser.
- Select "Other" radio button -> Select UTF-8 from the drop down
- Click Apply and OK button OR click simply OK button
- Window -> Preferences -> Expand General 并单击 Workspace,文本文件编码(靠近底部)有一个编码选择器。
- 选择“其他”单选按钮 -> 从下拉列表中选择 UTF-8
- 单击“应用”和“确定”按钮或单击“确定”按钮
回答by tommybee
You can set a default encoding-set whenever you run eclipse.exe.
您可以在运行 eclipse.exe 时设置默认编码集。
- Open eclipse.ini in your eclipse home directory Or STS.ini in case of STS(Spring Tool Suite)
- put the line below at the end of the file
- 在你的 eclipse 主目录中打开 eclipse.ini 或者在 STS(Spring Tool Suite) 的情况下打开 STS.ini
- 将下面的行放在文件末尾
-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 insall
command.
我尝试了这篇文章中提到的所有设置来成功构建我的项目,但这对我不起作用。最后我能够使用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_OPTIONS
with 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