Unicode blues in Python3

Martin v. Loewis martin at v.loewis.de
Tue Mar 23 18:42:47 EDT 2010


nn wrote:
> 
> Stefan Behnel wrote:
>> nn, 23.03.2010 19:46:
>>> Actually what I want is to write a particular byte to standard output,
>>> and I want this to work regardless of where that output gets sent to.
>>> I am aware that I could do
>>> open('nnout','w',encoding='latin1').write(mychar) but I am porting a
>>> python2 program and don't want to rewrite everything that uses that
>>> script.
>> Are you writing text or binary data to stdout?
>>
>> Stefan
> 
> latin1 charset text.

Are you sure about that? If you carefully reconsider, could you come to
the conclusion that you are not writing text at all, but binary data?

If it really was text that you write, why do you need to use
U+00FD (LATIN SMALL LETTER Y WITH ACUTE). To my knowledge, that
character is really infrequently used in practice. So that you try to
write it strongly suggests that it is not actually text what you are
writing.

Also, your formulation suggests the same:

"Is there any way to write a value 253 to standard output?"

If you would really be writing text, you'd ask


"Is there any way to write 'ý' to standard output?"

Regards,
Martin



More information about the Python-list mailing list