如何在Eclipse中支持UTF-8编码
如何在 eclipse 中添加 UTF-8 支持?我想添加例如俄语,但 eclipse 不支持它。我应该怎么办?请指导我。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(12)
试试这个
1)
窗口 >首选项>一般>内容类型
,将 UTF-8 设置为所有内容类型的默认编码。
2)
窗口 >首选项>一般>工作区
,设置文本文件编码
为其他:UTF-8
Try this
1)
Window > Preferences > General > Content Types
, set UTF-8 as thedefault encoding for all content types.
2)
Window > Preferences > General > Workspace
, setText file encoding
toOther : UTF-8
打开 Eclipse 并执行以下步骤:
Open Eclipse and do the following steps:
每当运行 eclipse.exe 时,您都可以设置默认编码集。
-Dfile.encoding=UTF-8
You can set a default encoding-set whenever you run eclipse.exe.
-Dfile.encoding=UTF-8
只需右键单击“项目”--“属性”,然后在左侧菜单中选择“资源”。
您现在可以将文本文件编码更改为您想要的任何内容。
Just right click the Project -- Properties and select Resource on the left side menu.
You can now change the Text-file encoding to whatever you wish.
右键单击主源 ->运行方式->运行配置-> (x)= 参数 -> VM 参数 ->添加:
Right click on main source -> Run As -> Run Configurations -> (x)= Arguments -> VM arguments -> add:
2022 年 9 月 24 日更新:
JDK 19(于 2022 年 9 月 20 日发布)具有
System
property可以设置为UTF-8,即添加以下选项
java< /代码>命令:
September 24, 2022 Update:
JDK 19 (released on September 20, 2022) has
System
propertywhich can be set to UTF-8, i.e. add the following option to the
java
command:如果您使用的是 Windows 11,并且之前的答案都不起作用,您可能需要更改您的区域设置。请按照下列步骤操作:
快速说明:
Windows 搜索 > 控制面板> 地区> 管理选项卡> 更改系统区域设置... > 检查
测试版:使用 Unicode UTF-8 实现全球语言支持
> 确定>立即重新启动完整说明:
Win
键,或只需单击搜索
按钮。另一种方法是按Win
+s
快捷键。enter
键将其打开,或者只需单击第一个搜索结果。View by
下拉菜单,然后选择Category
(如果未按Category设置视图)。时钟和区域
。区域
。管理
选项卡。更改系统区域设置...
按钮。测试版:使用 Unicode UTF-8 获得全球语言支持
选项。确定
。立即重新启动
。您应该能够在 Eclipse 中正确看到字符。
If you have Windows 11, and none of the previous answers worked, you could need to change your Region settings. Follow these steps:
Quick instructions:
Windows search > Control Panel > Region > Administrative tab > Change system locale... > check
Beta: Use Unicode UTF-8 for worldwide language support
> OK > Restart nowFull instructions:
Win
key, or just click on theSearch
button. Another way you can go is by pressing theWin
+s
shortcut.enter
key to open it, or simply click on the first search result.View by
dropdown menu in the upper right corner and selectCategory
(if the view is not set by Category).Clock and Region
.Region
.Administrative
tab.Change system locale...
button.Beta: Use Unicode UTF-8 for worldwide language support
option.OK
.Restart now
.You should be able to see the characters properly in Eclipse.
您可以通过将环境变量
JAVA_TOOL_OPTIONS
设置为值-Dfile.encoding="UTF-8"
来在操作系统范围内设置显式 Java 默认字符编码。下次启动 Eclipse 时,它应该坚持使用 UTF-8 作为默认字符集。请参阅 https://docs.oracle.com/javase /8/docs/technotes/guides/troubleshoot/envvars002.html
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.See https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/envvars002.html
如果您对 JSON 文件有问题,那么在某些 Eclipse 版本中会发现有一个嵌入式 JSON 验证器。您可以通过执行以下步骤将其关闭:
转到 Windows-> 验证并取消选中 JSON 验证复选框
If you have problems with JSON files, it turns out in some Eclipse versions there is an embedded JSON Validator. You can turn it off by doing the steps below:
Go to Windows->Validation and Uncheck JSON validation checkboxes
我尝试了这篇文章中提到的所有设置来成功构建我的项目,但这对我不起作用。最后,我能够使用
mvn -DargLine=-Dfile.encoding=UTF-8 clean install
命令成功构建我的项目。I tried all settings mentioned in this post to 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 install
command.就我而言,只需右键单击要更改编码的文件 ->
属性
并选择左侧菜单上的资源
。在文本文件编码
中单击其他
并更改为UTF-8。希望对您有所帮助。In my case, just right click on the file you want to change the encoding ->
Properties
and selectResource
on the left side menu. InText file encoding
clickother
and change to UTF-8. Hope to help you.您可能需要安装语言包:3.2
You may require to install Language Packs: 3.2