Linbreux/wikmd

Decoding issue in f.read() - Win10, python 3.11.2

Mik3Rizzo opened this issue · 1 comments

I installed wikmd in Windows 10, python3.11.2 (after a little bit of tweaking #97 )

I've got another error just after the wiki started:

Traceback (most recent call last):
  File "D:\Wiki (static)\wikmd\wiki.py", line 465, in <module>
    run_wiki()
  File "D:\Wiki (static)\wikmd\wiki.py", line 457, in run_wiki
    setup_search()
  File "D:\Wiki (static)\wikmd\wiki.py", line 442, in setup_search
    search.index_all(cfg.wiki_directory, items)
  File "D:\Wiki (static)\wikmd\search.py", line 87, in index_all
    content = f.read()
              ^^^^^^^^
  File "C:\dev\python\python311\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 0x90 in position 4807: character maps to <undefined>

It seems that f.read() tries to decode the file as CP1252 whereas it is encoded as UTF-8.

EDIT
I solved it adding encoding="utf8" where files are opened, like:

with open(file_path, encoding="utf8") as f:

Maybe I'll make a PR if I don't get other errors.

Nice to see you solved it. Feel free to create a PR from it :)