Ben1152000 / sootty

A command-line tool for displaying vcd waveforms.
BSD 3-Clause "New" or "Revised" License
44 stars 12 forks source link

Windows pathlib encoding error in README #62

Closed yihuajack closed 1 year ago

yihuajack commented 1 year ago

On Linux, this problem does not exist. On Windows, in setup.py,

README = (HERE / "README.md").read_text()

The read_text() function should have default value of optional argument encoding=None of utf-8, but it turns out that pathlib uses gbk:

Traceback (most recent call last): File "D:\Resources\sootty\setup.py", line 8, in README = (HERE / "README.md").read_text() File "E:\Program_Files\Python310\lib\pathlib.py", line 1135, in read_text return f.read() UnicodeDecodeError: 'gbk' codec can't decode byte 0x99 in position 702: illegal multibyte sequence

This occurs on README.md with line endings of CRLF. If the file is saved with endings of LF, the position is 700 because two line endings are "\n" instead of "\r\n". The character at that position is "’".

Two possible solutions:

  1. Change two characters "’" into "'";
  2. Explicitly specify read_text(encoding='utf-8')

However, the reason why this error occurs is still unknown.

Ben1152000 commented 1 year ago

Interesting, I've never seen this encoding before. It seems like the issue might be related to localization, since gbk is designed for simplified Chinese. If specifying the encoding solves the issue then that seems good.