File was loaded in the wrong encoding utf 8 как исправить

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:

enter image description here

GiovanyMoreno's user avatar

asked Apr 1, 2017 at 6:43

qg_java_17137's user avatar

qg_java_17137qg_java_17137

3,66810 gold badges41 silver badges80 bronze badges

5

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

answered Apr 1, 2017 at 6:53

aircraft's user avatar

3

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

enter image description here

answered Nov 20, 2017 at 16:32

soufien karray's user avatar

1

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

CHOOSE CRLF (image)

Machavity's user avatar

Machavity

30.6k27 gold badges91 silver badges100 bronze badges

answered Jan 29, 2019 at 6:00

Dinesh Sarma's user avatar

0

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.

answered Mar 14, 2018 at 14:36

Rodjf's user avatar

RodjfRodjf

1371 silver badge12 bronze badges

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

answered Sep 22, 2017 at 6:13

Umesh Sonawane's user avatar

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.

answered Jun 9, 2018 at 6:07

Francis Bacon's user avatar

Francis BaconFrancis Bacon

3,8401 gold badge34 silver badges46 bronze badges

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

answered Feb 5, 2020 at 15:39

Jimmy Alvarez's user avatar

Jimmy AlvarezJimmy Alvarez

5771 gold badge5 silver badges13 bronze badges

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
    print from File Encodings IntelliJ

By doing so, it did stop asking me to reload the file with the correct encoding.

answered Apr 6, 2021 at 22:01

s_bighead's user avatar

s_bigheads_bighead

97411 silver badges24 bronze badges

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.

enter image description here

When prompted, choose the following option:

enter image description here

answered Aug 12, 2022 at 11:04

ninjaPixel's user avatar

ninjaPixelninjaPixel

6,0333 gold badges36 silver badges47 bronze badges

from wsgiref import headers
import requests
from bs4 import BeautifulSoup

url = 'https://health-diet.ru/table_calorie/?utm_source=leftMenu&utm_medium=table_calorie'

headers = {
    "accept": "*/*",
    "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.134 YaBrowser/22.7.0.1842 Yowser/2.5 Safari/537.36"
}

req = requests.get(url, headers=headers)
src = req.text

with open("index.html", "w") as file:
    file.write(src)


  • Вопрос задан

    17 июл. 2022

  • 501 просмотр

Пригласить эксперта

Скрипт же записывает файл, а не открывает ?
В смысле не получается открыть этот ранее записанный ?

если MacOS или Linux то сделай так и файл будет корректный:

with open("index.html", "w", encoding="utf-8") as file:
    file.write(src)

если Windows:

with open("index.html", "w", encoding="cp1251") as file:
    file.write(src)


  • Показать ещё
    Загружается…

15 мая 2023, в 11:46

5000 руб./за проект

15 мая 2023, в 11:44

70000 руб./за проект

15 мая 2023, в 11:39

5000 руб./за проект

Минуточку внимания

I’m trying to save information in a file using pickle but when I open the file the information isn’t stored in binary format and I get the message

“File was loaded in the wrong encoding: UTF-8”

import pickle

with open('text.pickle', 'wb') as file:
    pickle.dump('some text', file)

bad_coder's user avatar

bad_coder

10.9k20 gold badges42 silver badges70 bronze badges

asked Sep 21, 2019 at 16:06

Dragomir Baltov's user avatar

To open a pickle file, in Python you’ll need to use pickle.load()

infile = open('text.pickle', 'rb')
new_dict = pickle.load(infile)
infile.close()

Look at this article on working with pickle

bad_coder's user avatar

bad_coder

10.9k20 gold badges42 silver badges70 bronze badges

answered Sep 21, 2019 at 16:15

Mikey Lockwood's user avatar

Mikey LockwoodMikey Lockwood

1,2581 gold badge9 silver badges22 bronze badges

Solution 1

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

Solution 2

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

enter image description here

Solution 3

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.

Solution 4

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

CHOOSE CRLF (image)

Related videos on Youtube

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

02 : 58

UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xff in position 0: invalid start byte

Code Pages, Character Encoding, Unicode, UTF-8 and the BOM - Computer Stuff They Didn't Teach You #2

17 : 18

Code Pages, Character Encoding, Unicode, UTF-8 and the BOM – Computer Stuff They Didn’t Teach You #2

How to make Emoji in Java with IntelliJ как запрограммировать смайлик в java на intellij idea

07 : 44

How to make Emoji in Java with IntelliJ как запрограммировать смайлик в java на intellij idea

HOWTO: Add Source Code Files to an IntelliJ Project

07 : 03

HOWTO: Add Source Code Files to an IntelliJ Project

how to solve encoding error (PNG,JPG,XML,JAVA) in android studio ?

03 : 45

how to solve encoding error (PNG,JPG,XML,JAVA) in android studio ?

001 File was loaded in the wrong encoding: 'UTF-8' in IntelliJ Idea.

02 : 55

001 File was loaded in the wrong encoding: ‘UTF-8’ in IntelliJ Idea.

Everything for the designer

File was loaded in wrong encoding utf-8 android - cannot load settings from file 'C:...app.iml'

02 : 09

File was loaded in wrong encoding utf-8 android – cannot load settings from file ‘C:…app.iml’

Cannot Load Settings From File || Parse Error At [..row,col];  [12,1 ]100% Worked !! Android Studio

02 : 21

Cannot Load Settings From File || Parse Error At [..row,col]; [12,1 ]100% Worked !! Android Studio

IntelliJ encoding issue

00 : 40

Comments

  • 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:

    enter image description here

    • See the hyperlink “reload in another encoding”? Click it!

    • Tarik…sure, but… What encoding was it loaded in? What encoding should it have instead been loaded in? If the IDE is aware it was loaded in the wrong one, why not load it in the right one? Something is happening here, and the reason is not clear. It would be good to know what is going on. Can anyone provide a little detail?

  • My suggestion: make a copy of the file and try to convert to a format. Then compare the files to find where the difference is. Right clicking on the content of the file you will find the “File Encoding” menu option where you can change the encoding even if the IDE is not complaining about it. When I tried to convert it back to UTF-8 it showed an error message and gave a guess of what would be the correct format. At the end I found the problem was in the “jalapeño” word, so I fixed it manually and saved it as UTF-8 at the end.

  • Exactly my case, but now the gradle complains like “Error: The file name must end with .xml”, any clues?

  • when you choose UTF-8 again, you need to click on the button “convert” when pop appear

Recents

Related

File was loaded in the wrong encoding: ‘UTF-8’

Error analysis: When we open a file, but Chinese is garbled, this is probably because our file is edited using UTF-8, and Windows uses the GBK encoding format by default, so it causes garbled characters when opening the file.

Solution one: Resolved in the open text (the palliative is not a cure). Click UTF-8 in the lower right corner of the figure, select GBK, and select Reload in the pop-up window.

Solution two: Sets the specified encoding format when editing text.

Добавить комментарий