Eclipse 中的 Java 属性 UTF-8 编码
我最近不得不将我正在处理的 web 应用程序的编码从 ISO-xx
切换到 utf8
.一切都很顺利,除了属性文件.我在 eclipse.ini
中添加了 -Dfile.encoding=UTF-8
并且正常文件工作正常.然而,属性表现出一些奇怪的行为.
I've recently had to switch encoding of webapp I'm working on from ISO-xx
to utf8
. Everything went smooth, except properties files. I added -Dfile.encoding=UTF-8
in eclipse.ini
and normal files work fine. Properties however show some strange behaviour.
如果我从 Notepad++ 复制 utf8
编码的属性并将它们粘贴到 Eclipse 中,它们会显示并正常工作.当我重新打开属性文件时,我看到一些 Unicode 字符而不是正确的字符,例如:
If I copy utf8
encoded properties from Notepad++ and paste them in Eclipse, they show and work fine. When I reopen properties file, I see some Unicode characters instead of proper ones, like:
Zuru00EFu00BFu00BDck instead of Zurück
但应用程序仍然可以正常工作.如果我开始编辑属性,添加一些特殊字符并保存,它们会正确显示,但是它们不起作用并且所有以前工作的特殊字符不再起作用.
but app still works fine. If I start to edit properties, add some special characters and save, they display correctly, however they don't work and all previously working special characters don't work any more.
当我将本地版本与 CVS 进行比较时,我可以在远程文件上正确看到特殊字符,更新后我又开始了:应用程序可以工作,但 Eclipse 显示 Unicode 字符.
When I compare local version with CVS I can see special characters correctly on remote file and after update I'm at start again: app works, but Eclipse displays Unicode chars.
我尝试通过右键单击文件并选择其他:UTF8"来更改文件编码,但没有帮助.它还说:根据内容确定:ISO-8859-1"
I tried changing file encoding by right clicking it and selecting „Other: UTF8" but it didn't help. It also said: „determined from content: ISO-8859-1"
我使用的是基于 Eclipse 3.3 的 Java 6 和 Jboss Developer
I'm using Java 6 and Jboss Developer based on Eclipse 3.3
我可以通过在 Notepad++ 中编辑属性并将它们粘贴到 Eclipse 中来接受它,但如果有人能帮助我在 Eclipse 中修复此问题,我将不胜感激.
I can live with it by editing properties in Notepad++ and pasting them in Eclipse, but I would be grateful if someone could help me with fixing this in Eclipse.
Don't waste your time, you can use Resource Bundle plugin in Eclipse