PyCharm txt file encoding

Hi, I started use PyCharm and I have a littel problem with file encoding. I have created a project and I found out it is not in UTF-8 encoding. So according this doc https://www.jetbrains.com/help/pycharm/settings-file-encodings.html I set the project and system encoding to UTF-8. Everything works fine but there is one txt file which I use to write some content. The content is ok but if I open this file in editor there are some question marks like in wrong encoding. It looks like on the picture. What should i set to have a correct wiev?

Here are the settings:

NEXT problem I found out with test.txt is that if its content is filled by script it works fine BUT if it is filled by hands it throws me an error: File "C:\Program Files\Python37\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position 32: character maps to <undefined>

1 comment
Comment actions Permalink

Hi,

Problem 1: The file is opened in UTF-8 encoding, and what you see is what is actually decoded using UTF-8. Try opening in other editors like Sublime Text in UTF-8, you will likely see the same.

Problem 2: Seems like PyCharm has nothing to do with it - python doesn't like the encoding your file is saved in.

0

Please sign in to leave a comment.