‘cp932’ codec can’t encode character ‘\xa1’ in position 62: illegal multibyte sequence

When using print in python with some multibyte character or when decoding from another encoding you might encounter this fatal error:

Traceback (most recent call last): File "skynet.py", line 28, in print(skyname_wakeup_word) UnicodeEncodeError: 'cp932' codec can't encode character '\xa1' in position 62: illegal multibyte sequence

To sort of fix it, you can use

skyname_wakeup_word.encode('cp932',"ignore")

This occurs because python can’t convert that character to the traditional windows ansi used in windows terminal (cmd). cp932 is code page 932 the Japanese version of shift-JIS.
Other encodings: cp874, cp936, cp949, cp950, cp1251, cp1252, cp1253, cp1254, cp1255, cp1256, cp1257, cp1258. Source

Leave a Reply

Your email address will not be published. Required fields are marked *

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.