简体   繁体   English

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

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

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 工作室中的“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打开它,得到这个问题:

在此处输入图像描述

正如 Tarik 所指出的,点击Reload in another encoding ,如果你想要UTF-8编码,然后点击more -> UTF-8

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

在此处输入图片说明

You can try opening your file with an other text editor, like Notepad++.您可以尝试使用其他文本编辑器(如 Notepad++)打开文件。 Sometimes it can detect the correct encoding of your file, using a different pattern than IntelliJ.有时它可以使用与 IntelliJ 不同的模式检测文件的正确编码。 Then you will be able to use the "Reload..." of IntelliJ.然后您将能够使用 IntelliJ 的“重新加载...”。

I was having the same problem.. and i solved it by changing the CR to CRLF AND then refresh the project like done in following image我遇到了同样的问题..我通过将CR更改为CRLF然后刷新项目来解决它,如下图所示

选择 CRLF(图片)

Click on setting symbol just right side of error and select suppress for class.单击错误右侧的设置符号,然后为类选择抑制。 That works for me and resolve my issue.这对我有用并解决了我的问题。

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.然后我们就可以看到汉字了。

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 version its work fine and 100% 我尝试了更多的时间来解决这个问题,但我不能得到实际的进展,但我解决这个问题与减少Android工作室版本的工作正常和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)

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

Though the encoding setting was present in the pom.xml, IntelliJ was trying to load all test files using UTF-8 instead of ISO-8859-1, so I found this in the IntelliJ docs: Encoding in IntelliJ Which, it basically was...尽管 pom.xml 中存在编码设置,但 IntelliJ 尝试使用 UTF-8 而不是 ISO-8859-1 加载所有测试文件,所以我在 IntelliJ 文档中发现了这一点: 在 IntelliJ 中编码,基本上就是这样。 ..

  1. Open preferences (in macOS hit, command + , )打开首选项(在 macOS 中, command + ,
  2. Go to Editor / File Encodings转到编辑器/文件编码
  3. Select the project correct encoding if it defers from your pom.xml - project.build.sourceEncoding如果项目与您的pom.xml - project.build.sourceEncoding延迟,请选择项目正确的编码从文件编码 IntelliJ 打印

By doing so, it did stop asking me to reload the file with the correct encoding.通过这样做,它确实不再要求我使用正确的编码重新加载文件。

If you have previously loaded this file without problems, and this is a new issue for you, try invalidating the caches in your IDE.如果您之前加载此文件没有问题,而这对您来说是一个新问题,请尝试使 IDE 中的缓存无效。

An easy way to open this option is by opening the super-search functionality (hit shift twice) and search for 'cache' in the 'actions' tab.打开此选项的一种简单方法是打开超级搜索功能(按两次 shift)并在“操作”选项卡中搜索“缓存”。

在此处输入图像描述

When prompted, choose the following option:出现提示时,选择以下选项:

在此处输入图像描述

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM