eclipse 无法创建带有外语字符的文件

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

Unable to create a file with foreign language characters

eclipseencodinginternationalizationproperties

提问by Joe

I get the following error, when trying to save a properties file (containing name/value pairs) with foreign language characters. How do I set the encoding?

尝试使用外语字符保存属性文件(包含名称/值对)时,出现以下错误。如何设置编码?

Save could not be completed. Some characters cannot be mapped using "Cp1252" character encoding. Either change the encoding or remove the characters which are not supported by the "Cp1252" character encoding.

无法完成保存。某些字符无法使用“Cp1252”字符编码进行映射。更改编码或删除“Cp1252”字符编码不支持的字符。

回答by satya

I presume its eclipse:

我认为它的日食:

  1. Go to Windows Menu –> Preferences –> General (expand it) –> Workspace (click on it)
  2. Look for a box “Text File Encoding”. Default will be “Cp1252″.
  3. Change radio to select other and select “UTF-8″ from combo box.
  1. 转到 Windows 菜单 –> 首选项 –> 常规(展开它)–> 工作区(单击它)
  2. 寻找“文本文件编码”框。默认值为“Cp1252”。
  3. 更改单选以选择其他并从组合框中选择“UTF-8”。

回答by Roland Illig

That looks like Eclipse.

这看起来像 Eclipse。

  1. Cut the whole contents of the file into the clipboard.
  2. Save the (now empty) properties file.
  3. Change the encoding settings of the file (Alt+Enter) to be UTF-8 or whatever you need.
  4. Paste the clipboard into the editor.
  5. Save the editor.
  1. 将文件的全部内容剪切到剪贴板中。
  2. 保存(现在是空的)属性文件。
  3. 将文件的编码设置 (Alt+Enter) 更改为 UTF-8 或任何您需要的。
  4. 将剪贴板粘贴到编辑器中。
  5. 保存编辑器。

回答by spacewanderer

Assuming it is in Eclipse, easiest way is to choose Save as UTF-8option present in the error dialog box.

假设它在 Eclipse 中,最简单的方法是选择出现在错误对话框中的Save as UTF-8选项。

enter image description here

在此处输入图片说明

The other answers work well too.

其他答案也很有效。

回答by gaurav_

Best possible solution for this , which I always do .Is to go the respective file in your workspace open it in notepad++ and make the desired changes. Once done , save the file. Your eclipse will ask you to update the code with the changes . Click yes. And you are all good to go now.

对此的最佳解决方案,我总是这样做。是去工作区中的相应文件在记事本++中打开它并进行所需的更改。完成后,保存文件。您的 Eclipse 会要求您使用更改来更新代码。单击是。你们现在都可以走了。

回答by srinath

Fist copy the file and delete that file and then cleat your code in the eclipse after

拳头复制文件并删除该文件,然后在 eclipse 中清除您的代码

create file with same content and rewrite the code it will resolve.

创建具有相同内容的文件并重写它将解析的代码。