On Wed, May 5, 2010 at 2:49 PM, Itamar Turner-Trauring <ita...@itamarst.org> wrote: > 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?
If I print as you do it works, but my string is fetched from database and only then it fails > > > _______________________________________________ > Twisted-Python mailing list > Twisted-Python@twistedmatrix.com > http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python > _______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python