在 Eclipse 中更改编码

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21262519/
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 22:00:37  来源:igfitidea点击:

Change encoding in Eclipse

eclipseencoding

提问by bukka.wh

I was working on my project in Windows using Eclipse (and I didn't check that my encoding was CP-1251). Now am going to work with my project in Linux with Eclipse too, but with UTF8 encoding, so all my comments are now non readable.

我正在使用 Eclipse 在 Windows 中处理我的项目(我没有检查我的编码是否为 CP-1251)。现在我也将使用 Eclipse 在 Linux 中处理我的项目,但是使用 UTF8 编码,所以我所有的评论现在都无法阅读。

Can I just reconvert them into UTF using Eclipse?

我可以使用 Eclipse 将它们重新转换为 UTF 吗?

回答by Arnaud Potier

You can set up the encoding used by eclipse in the Preferences section

您可以在 Preferences 部分设置 eclipse 使用的编码

Window -> Preferences -> General -> Workspace -> Text file encoding

窗口 -> 首选项 -> 常规 -> 工作区 -> 文本文件编码

You can also override it for a single project only if that is the only project you are having trouble with.

仅当您遇到问题的唯一项目时,您也可以为单个项目覆盖它。

回答by Bartek B.

There is a plugin for Eclipse"Autodetect Encoding" - you can detect/convert the encoding in files. It can be found in the Help->Marketplace...

Eclipse“自动检测编码”有一个插件- 您可以检测/转换文件中的编码。它可以在帮助->市场中找到...

I just started testing, but it works so far.

我刚开始测试,但到目前为止它有效。

Hint: sometimes you need to change the detector to ICU4j

提示:有时需要将检测器改为ICU4j

And even if the convert does not work in a current document (because of detection) you can do this: CTRL+Con one enconding switch to another and CTRL+Vit will paste correct then save.

即使转换在当前文档中不起作用(由于检测),您也可以这样做: CTRL+C在一个编码切换到另一个编码时,CTRL+V它会正确粘贴然后保存。