ewx: (geek)
Richard Kettlewell ([personal profile] ewx) wrote2007-12-15 04:41 pm
Entry tags:

Stupid Python

chymax$ python -V
Python 2.5.1
chymax$ python -c 'print u"\xA9";'
©
chymax$ python -c 'print u"\xA9";' >/dev/null
Traceback (most recent call last):
  File "<string>", line 1, in 
UnicodeEncodeError: 'ascii' codec can't encode character u'\xa9' in position 0: ordinal not in range(128)
chymax$ locale
LANG=
LC_COLLATE="C"
LC_CTYPE="en_GB.utf-8"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL="C/en_GB.utf-8/C/C/C/C"
cjwatson: (Default)

[personal profile] cjwatson 2007-12-18 10:42 am (UTC)(link)
Should be sufficient to replace 'UTF-8' with locale.getpreferredencoding() (not tested).