[Twisted-Python] print unicode

Itamar Turner-Trauring itamar at itamarst.org
Wed May 5 08:49:57 EDT 2010


On Wed, 2010-05-05 at 13:45 +0200, Pet wrote:
> Hello!
> 
> I'm using Twisted 10.0 and as usually sometime print debug infos with
> myunicodestr.encode('UTF-8') which are saved to logfile, but since
> using twisted 10 I'm getting
> 
> UnicodeEncodeError: 'ascii' codec can't encode characters...
> 
> type(myunicodestr) returns <type 'unicode'>
> 
> 
> What is the problem here?

This works fine for me (Twisted trunk):

$ python2.5 -c "import sys; from twisted.python import log; \
log.startLogging(file('/tmp/log', 'w')); print \
u'\u1234'.encode('UTF-8')"
$ cat /tmp/log 
2010-05-05 08:48:40-0400 [-] Log opened.
2010-05-05 08:48:40-0400 [-] ሴ

Can you include a minimal reproducing example?




More information about the Twisted-Python mailing list