Python, PyGame UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 0: ordinal not in range(128)
I'm aware to the other answers to similar questions but none of them solved my problem.
This is my code:
# coding=utf-8
W = "─│"
ENCODING = "utf-8"
def maze():
tr_list = pygame.sprite.Group()
count_i = 0
count_j = 0
f = codecs.open("files/ma.txt", mode="r+", encoding=ENCODING)
# Open file as f
read = f.read().splitlines()
f.close()
for line in read:
for m in line:
if m in W:
if m == '│':
tr_list.add(MazeV(count_j, count_i))
elif m == '─':
tr_list.add(MazeH(count_j, count_i))
count_j += ADD
count_i += ADD
return tr_list
This is the error when I run the code:
File "/Users/user/Documents/Pact/Main.py", line 637, in <module>
main()
File "/Users/user/Documents/Pact/Main.py", line 121, in main
wall_list = maze() # Set up the maze
File "/Users/user/Documents/Pact/Main.py", line 493, in maze
if i in WALL: # If wall
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 0:
ordinal not in range(128)
I tried encoding and decoding to many formats, but the problem keeps the same. Is there anything that I can do?
This is ma.txt:
Thanks in advance
MazeV?