- edited description
-
assigned issue to
Unable to print unicode characters due to incorrect locale
grabber.py is crashing with the following error message when listing the available programs. Doesn't occur for all programming listings.
Sequence performed on 6/aug/15
Run grabber.py
Select Station: SBS (3) Select Channel: SBS1 (2)
Crash occurs during program listing
Traceback (most recent call last):
File "./grabber.py", line 61, in <module>
main()
File "./grabber.py", line 46, in main
result = choose(options, allow_multi=will_download)
File "./grabber.py", line 15, in choose
print("%3d) %s" % (i+1, key))
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2018' in position 45: ordinal not in range(128)
Comments (6)
-
repo owner -
Account Deleted reporter I am a using OS X 10.8
Slim:webdl tom$ which python /usr/bin/python Slim:webdl tom$ python --version Python 2.7.2 Slim:webdl tom$ locale LANG= LC_COLLATE="C" LC_CTYPE="C" LC_MESSAGES="C" LC_MONETARY="C" LC_NUMERIC="C" LC_TIME="C" LC_ALL= Slim:webdl tom$ uname Darwin
Looks like the problem is the Locale is not UTF-8 or LC_CTYPE=C might be the problem?
Any idea how to you change it?
-
repo owner - changed status to invalid
I don't use Mac OSX, but a quick Google search suggests you may be able to configure this in Terminal.app Preferences.
Worst case you can just put
export LC_CTYPE=en_AU.UTF-8
or equivalent into your shell configuration. -
repo owner - changed title to Unable to print unicode characters due to incorrect locale
-
Account Deleted reporter The fix is to add the following lines to your .bash_profile file :
# Setting for the new UTF-8 terminal support in Lion export LC_CTYPE=en_US.UTF-8 export LC_ALL=en_US.UTF-8
Solution found here:
https://yzisin.wordpress.com/2012/01/09/how-to-fix-locale-issues-in-mac-os-x-lion-terminal/
-
repo owner Issue
#25was marked as a duplicate of this issue. - Log in to comment
I can't reproduce this with Python2 or Python3. What version of Python are you running?
What's the output of running the command
locale
? You should be using UTF-8.I can only reproduce this if I set
LC_CTYPE=C
.