can’t encode character ‘\u0144’ even using encoding=utf-8 in python3

I am trying to read some information from some .txt files, they are all in english and they do not have any other unicode character, the problem is that for an especific file it just crashed and do not show the information, the error is

Traceback (most recent call last):
  File "C:\users\bienvenido\desktop\programmacion\harvard\cs50 artificial inteligence\6\questions\", line 107, in <module>
  File "C:\users\bienvenido\desktop\programmacion\harvard\cs50 artificial inteligence\6\questions\", line 16, in main
    files = load_files(sys.argv[1])
  File "C:\users\bienvenido\desktop\programmacion\harvard\cs50 artificial inteligence\6\questions\", line 59, in load_files
    files[file] =
  File "C:\Users\BIENVENIDO\AppData\Local\Programs\Python\Python39\lib\encodings\", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 38619: character maps to <undefined>

and what i am doing is

with open(os.path.join(directory,file), encoding='utf-8') as f:
    files[file] =

I also tried utf16 and default encoding

Read more here:

Content Attribution

This content was originally published by jhonny at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: