Java 文件以错误的编码加载:IntelliJ IDEA 中的“UTF-8”

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

File was loaded in the wrong encoding:'UTF-8' in IntelliJ IDEA

javaintellij-ideaencodingutf-8

提问by qg_java_17137

Before asking the question, I searched for a similar question on StackOverflow:

在问这个问题之前,我在 StackOverflow 上搜索了一个类似的问题:

file was loaded in the wrong encoding: 'UTF-8' in android studio

文件以错误的编码加载:android studio 中的“UTF-8”

But it did not give an explicit answer there.

但它没有在那里给出明确的答复。



My issue is that the project is downloaded from the network, and it is an eclipse project, I open it with IntelliJ IDEA, and get this issue:

我的问题是项目是从网络下载的,而且是eclipse项目,我用IntelliJ IDEA打开,得到这个问题:

enter image description here

在此处输入图片说明

回答by aircraft

As Tarik point out, click the Reload in another encoding, and if you want UTF-8encoding, then click the more-> UTF-8.

正如 Tarik 所指出的,单击Reload in another encoding,如果您想要UTF-8编码,则单击more-> UTF-8

回答by Umesh Sonawane

Click on setting symbol just right side of error and select suppress for class. That works for me and resolve my issue.

单击错误右侧的设置符号,然后为类选择抑制。这对我有用并解决了我的问题。

回答by soufien karray

in my case , when i uploaded the first .ttf file in assert folder , android studio asked me to choose one file type , and when I selected text type . this problem start to appear . the right file type is : 'Files Opened In Associated Applications'.to fix your problem , you have to open preferences ->Editor ->File Types and search for .ttf extension then remove it and add it again under 'Files Opened In Associated Applications' enter image description here

就我而言,当我在 assert 文件夹中上传第一个 .ttf 文件时,android studio 要求我选择一种文件类型,当我选择文本类型时。这个问题开始出现。 正确的文件类型是:“在相关应用程序中打开的文件”。要解决您的问题,您必须打开首选项 -> 编辑器 -> 文件类型并搜索 .ttf 扩展名,然后将其删除并在“在相关应用程序中打开的文件”下再次添加 在此处输入图片说明

enter image description here

在此处输入图片说明

回答by Rodjf

You can try opening your file with an other text editor, like Notepad++. Sometimes it can detect the correct encoding of your file, using a different pattern than IntelliJ. Then you will be able to use the "Reload..." of IntelliJ.

您可以尝试使用其他文本编辑器(如 Notepad++)打开文件。有时它可以使用与 IntelliJ 不同的模式检测文件的正确编码。然后您将能够使用 IntelliJ 的“重新加载...”。

回答by Francis Bacon

My colleague works on Windows while I work on Ubuntu 16.04

我的同事在 Windows 上工作,而我在 Ubuntu 16.04 上工作

Click the Reload in another encoding, and click the more -> GBK.

单击另一种编码中的重新加载,然后单击更多 -> GBK。

Then we can see the Chinese character.

然后我们就可以看到汉字了。

回答by Dinesh Sarma

I was having the same problem.. and i solved it by changing the CRto CRLFAND then refresh the project like done in following image

我遇到了同样的问题..我通过将CR更改为CRLF然后刷新项目来解决它,如下图所示

CHOOSE CRLF (image)

选择 CRLF(图片)

回答by Vithani Ravi

I was having the same problem. i was try many more time to solved this issue but i cant get actual progress but i'm Solving this problem with decrease android studio versionits work fine and 100%

我遇到了同样的问题。我尝试了更多时间来解决这个问题,但我无法获得实际进展,但我正在通过降低 android studio 版本来解决这个问题,它的工作正常且 100%

Download Link : https://android-studio.en.uptodown.com/windows/download(3.2.1.0)

下载链接:https://android-studio.en.uptodown.com/windows/download (3.2.1.0)

回答by Jimmy Alvarez

I tried all possibilities posted here but any success with them, what worked was just to re import the project

我尝试了这里发布的所有可能性,但任何成功,有效的只是重新导入项目

回答by Benny

Simply just delete the IDE's Settings Directory,

只需删除IDE的设置目录,

See the answer here: file was loaded in the wrong encoding: 'UTF-8' in the Android Studio

请参阅此处的答案: file was loaded in the wrong encoding: 'UTF-8' in the Android Studio