Unable to print unicode characters due to incorrect locale

Issue #23 invalid
Former user created an issue

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)

  1. delx repo owner
    • edited description
    • assigned issue to
      delx

    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.

  2. Former user 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?

  3. delx repo owner

    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.

  4. Log in to comment