简体   繁体   中英

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

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

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

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:

在此处输入图像描述

正如 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 . 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'在此处输入图片说明

在此处输入图片说明

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.

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

选择 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

Click the Reload in another encoding, and click the more -> 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%

Download Link : 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...

  1. Open preferences (in macOS hit, command + , )
  2. Go to Editor / File Encodings
  3. Select the project correct encoding if it defers from your 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.

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.

在此处输入图像描述

When prompted, choose the following option:

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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