简体   繁体   English

CP1252转UTF-8编码后的特殊字符

[英]Special characters after converting from CP1252 to UTF-8 encoding

I have a bulk of Java-files in Eclipse that was written when my Eclipse had CP1252 as encoding.我在 Eclipse 中有大量 Java 文件,这些文件是在我的 Eclipse 使用CP1252作为编码时编写的。 I am in Sweden and we have special character (Å å Ä ä Ö ö) .我在瑞典,我们有特殊的性格(Å å Ä ä Ö ö) Now we have changed the encoding to UT-8 .现在我们已将编码更改为UT-8 All special characters is ruined now to strange characters instead!!所有特殊字符现在都被毁坏为奇怪的字符!! Is there any other solution instead of open each file and rewrite all the special characters again?有没有其他解决方案而不是打开每个文件并再次重写所有特殊字符?

I was facing the same issue in my project.我在我的项目中遇到了同样的问题。 Here are the steps that I followed:以下是我遵循的步骤:

  1. I first copied the contents of the file to notepad++(copy to any editor which supports utf-8).我首先将文件的内容复制到记事本++(复制到任何支持 utf-8 的编辑器)。
  2. Eclipse uses the cp1252 encoding for files by default on Windows.默认情况下,Eclipse 在 Windows 上对文件使用 cp1252 编码。 After copying file contents, you need to change the encoding to utf-8.复制文件内容后,您需要将编码更改为 utf-8。 You can do this by going to Window->Preferences->Workspace.您可以通过转到 Window->Preferences->Workspace 来完成此操作。 There you will find text file encoding, change it to utf-8 and apply and close.在那里您将找到文本文件编码,将其更改为 utf-8 并应用并关闭。 You will notice that characters like (Å å Ä ä Ö ö) have changed to some strange characters.你会注意到像 (Å å Ä ä Ö ö) 这样的字符已经变成了一些奇怪的字符。
  3. Copy the contents that you had saved in the notepad++(or your editor) to the file in eclipse and save the file.将您在记事本++(或您的编辑器)中保存的内容复制到 eclipse 中的文件中并保存该文件。 That's it!就是这样!

Run your project, it should not give any warnings or errors for those characters now.运行您的项目,它现在不应该为这些字符提供任何警告或错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从Cp1252到UTF-8的Spring MVC编码请求 - Spring MVC encode request from Cp1252 to UTF-8 编码cp1252 - Encoding cp1252 如何可靠地猜测 MacRoman、CP1252、Latin1、UTF-8 和 ASCII 之间的编码 - How to reliably guess the encoding between MacRoman, CP1252, Latin1, UTF-8, and ASCII 即使字符串采用UTF-8,电子邮件主题仍以CP1252编码设置 - EMail subject get set in CP1252 encoding even though the string is in UTF-8 为什么我的简化DES实现在Cp1252编码下可以正常工作,而在UTF-8下却不能正常工作? - Why is my implementation of Simplified DES working fine under Cp1252 encoding but not under UTF-8? 有没有办法使用 java 查找文件编码类型(UTF-8 或 ANSI 或 Cp1252 或其他) - Is there a way to find file encoding type (UTF-8 or ANSI or Cp1252 or others) using java 从UTF-8格式的pdf文件中读取并将其写入cp1252格式的写入器中 - Reading from UTF-8 formatted pdf file and writing it to a writer in cp1252 format 将cp-1252编码为utf-8? - Encoding cp-1252 as utf-8? 每次启动/重新启动Eclipse时,它都会将文本文件编码更改为其他:UTF-8而不是默认值(Cp1252) - Every time I start/restart Eclipse it changes the Text File Encoding to Other: UTF-8 instead of the Default (Cp1252) 将文件从cp1252转换为utf -8 java - Convert file from Cp1252 to utf -8 java
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM