devbisme / KiField

Edit/insert/delete part fields in KiCad schematics or libraries using a spreadsheet.
MIT License
70 stars 27 forks source link

UnicodeDecodeError: 'gbk' codec can't decode byte 0xa8 in position 1144: illegal multibyte sequence #79

Open lyrain2009 opened 9 months ago

lyrain2009 commented 9 months ago

Screenshots image Desktop (please complete the following information):

lyrain2009 commented 9 months ago

Kicad info: Kicad Application: KiCad x64 on x64 Version: 7.0.9, release build

lyrain2009 commented 9 months ago

image add encoding='utf-8', problem solved

devbisme commented 9 months ago

Since you've identified the problem and have a potential fix, why not just issue a pull request?

lyrain2009 commented 9 months ago

Since you've identified the problem and have a potential fix, why not just issue a pull request? Thanks.

I find it's not a good ideal to modify source file,because all the open function in source shoud be added "encoding='utf-8' ".

the reason of UnicodeDecodeError is the system encoding method,because when python open file,it use system default encoding. I use windows in china,the default encoding is 'gbk',so when python open file ,it use 'gbk' codec to decode utf-8 file that cause error. So the solution is set Python to utf-8 mode,just set the PYTHONUTF8=1 environment variable,no need to modify source file. Python: Use the UTF-8 mode on Windows!