Prev: using message loop for hotkey capturing
Next: Miracles of the devil and beat of the revolution of religious reform
From: nn on 23 Mar 2010 16:36 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.
From: Martin v. Loewis on 23 Mar 2010 18:42 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
From: Steven D'Aprano on 24 Mar 2010 00:41 On Tue, 23 Mar 2010 11:46:33 -0700, nn wrote: > 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. What do you mean "work"? Do you mean "display a particular glyph" or something else? In bash: $ echo -e "\0101" # octal 101 = decimal 65 A $ echo -e "\0375" # decimal 253 � but if I change the terminal encoding, I get this: $ echo -e "\0375" ý Or this: $ echo -e "\0375" ² depending on which encoding I use. I think your question is malformed. You need to work out what behaviour you actually want, before you can ask for help on how to get it. -- Steven
From: nn on 24 Mar 2010 09:03 Martin v. Loewis wrote: > 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 To be more informative I am both writing text and binary data together. That is I am embedding text from another source into stream that uses non-ascii characters as "control" characters. In Python2 I was processing it mostly as text containing a few "funny" characters.
From: nn on 24 Mar 2010 09:08 Steven D'Aprano wrote: > On Tue, 23 Mar 2010 11:46:33 -0700, nn wrote: > > > 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. > > What do you mean "work"? > > Do you mean "display a particular glyph" or something else? > > In bash: > > $ echo -e "\0101" # octal 101 = decimal 65 > A > $ echo -e "\0375" # decimal 253 > � > > but if I change the terminal encoding, I get this: > > $ echo -e "\0375" > ý > > Or this: > > $ echo -e "\0375" > ² > > depending on which encoding I use. > > I think your question is malformed. You need to work out what behaviour > you actually want, before you can ask for help on how to get it. > > > > -- > Steven Yes sorry it is a bit ambiguous. I don't really care what glyph is, the program reading my output reads 8 bit values expects the binary value 0xFD as control character and lets everything else through as is.
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: using message loop for hotkey capturing Next: Miracles of the devil and beat of the revolution of religious reform |