UnicodeDecodeError when executing duplicate.py in Korean Windows (CP949) #1023
Labels
bug
Something isn't working
build system / structure
issue relates to the build system or folder layout
Describe the bug
Hello,
Recently I came across to this awesome project and trying tutorials in the Wiki page.
But if I run the
Example/duplicate.py
in Windows terminal(PowerShell), the code crashes with UnicodeDecodeError in Line 73.To Reproduce
Run
python .\duplicate.py IPlugEffect MyNewPlugin MyNewManufacturer
in Windows Terminal (or PowerShell).Expected behaviour
After I add paramter "encoding="utf-8" like
for line in fileinput.input(files,inplace=1,encoding="utf-8"):
to following lines of code, it run successfully with no errors.iPlug2/Examples/duplicate.py
Line 73 in fe1ca6f
iPlug2/Examples/duplicate.py
Line 80 in fe1ca6f
Screenshots
IMPORTANT DETAILS
Additional context
In the error message
UnicodeDecodeError: 'cp949' codec can't decode byte 0xbf in position 2: illegal multibyte sequence
, cp949 is Korean encoding made by Microsoft Windows (maybe like Japanese encoding of EUC-JP?).Even in Windows 11, the default encoding in Korean Windows is CP949.
It could be awkward that why the encoding of text(code) files cloned from this repository is regarded as CP949, not ASCII.
Maybe CP949 is made to be superset of ASCII, so Korean Windows always regard ASCII text file as CP949.
It seems that my solution(adding encoding parameter) can only be work in the Python >= 3.10 .
https://stackoverflow.com/a/69508474
If this matters, fileinput.input may be replaced to another function to prevent the encoding issue?
The text was updated successfully, but these errors were encountered: