[Twisted-Python] print unicode

Pet petshmidt at googlemail.com
Wed May 5 06:31:31 MDT 2010


On Wed, May 5, 2010 at 2:05 PM, Maarten ter Huurne
<maarten at treewalker.org> wrote:
> On Wednesday 05 May 2010, Pet wrote:
>
>> 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...
>
> UTF-8 uses the full 8 bits of a byte, while ASCII only uses 7, so writing
> Unicode encoded as UTF-8 to an ASCII stream is not valid.
>
> I think recent Python versions are more strict about what is written to
> stdout/stderr than older versions, it might not be related to Twisted
> itself. You can specify a different encoding for stdin/out/err by setting
> the PYTHONIOENCODING environment variable.

Hi Maarten!

Thanks for help!
Unfortunately, my Python installation is 2.5.2 and PYTHONIOENCODING is
introduced in 2.6

Pet
>
> Bye,
>                Maarten
>
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>




More information about the Twisted-Python mailing list