UnicodeDecodeError when dealing with international characters
Hello,
I was using this great script a long ago, and recently I moved to Ubuntu Server 14.04.2 LTS. I reinstalled the script and suddenly I got a strange error message:
tulio@ubuntusvr:~/P2P$ cpq Adventures*.jpg ~/Vídeos Traceback (most recent call last): File "/home/tulio/bin/cpq", line 159, in <module> main() File "/home/tulio/bin/cpq", line 154, in main process(next_id, sys.argv[1:]) File "/home/tulio/bin/cpq", line 139, in process args = [shellquote(s) for s in args] File "/home/tulio/bin/cpq", line 127, in shellquote return "'" + s.replace("'", "'\\''") + "'" UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 13: ordinal not in range(128)
This happens when there are special portuguese language characters in arguments. For instance, my LOCALE settings follows:
tulio@ubuntusvr:~/P2P$ locale LANG=pt_BR.UTF-8 LANGUAGE=pt_BR.UTF-8 LC_CTYPE="pt_BR.UTF-8" LC_NUMERIC=pt_BR.UTF-8 LC_TIME=pt_BR.UTF-8 LC_COLLATE="pt_BR.UTF-8" LC_MONETARY=pt_BR.UTF-8 LC_MESSAGES="pt_BR.UTF-8" LC_PAPER=pt_BR.UTF-8 LC_NAME=pt_BR.UTF-8 LC_ADDRESS=pt_BR.UTF-8 LC_TELEPHONE=pt_BR.UTF-8 LC_MEASUREMENT=pt_BR.UTF-8 LC_IDENTIFICATION=pt_BR.UTF-8 LC_ALL=
Thank you in advance.
I also get this error message regularly in other Python projects of mine. I'm afraid I don't have a nice solution for this problem.