用vscode上的PlatformIO开发arduino,最近总是显示报错,
UnicodeDecodeError: 'gbk' codec can't decode byte 0xaf in position 706: illegal multibyte sequence
经过一番验证,是代码中写的中文注释引起的问题,但是死活找不出是哪个注释写的不对引起的。
虽然我的文件编码是utf-8, 但是python在读取时采用的是gbk编码读取的,于是就导致了这个注释也能影响编译的诡异bug。
于是点进PlatformIO中的python编译文件中看看它是怎么写的,
c:\users\xxxxxxx\.platformio\penv\lib\site-packages\platformio\proc.py,
把第33行, self._pipe_reader = os.fdopen(self._fd_read)
加上已utf-8读取就行了 self._pipe_reader = os.fdopen(self._fd_read, encoding='utf-8')