[Python-ideas] changing sys.stdout encoding (original) (raw)

Jim Jewett jimjjewett at gmail.com
Tue Jun 12 17:15:11 CEST 2012


On Fri, Jun 8, 2012 at 11:39 PM, Rurpy <rurpy at yahoo.com> wrote:

On 06/07/2012 03:00 PM, Mike Meyer wrote:

On Thu, Jun 7, 2012 at 4:48 PM, Rurpy <rurpy-/E1597aS9LQAvxtiuMwx3w at public.gmane.org> wrote:

how do other programming languages deal with wanting to change the encoding of the standard IO streams?

This is how it seems to be done in Perl:

 binmode(STDOUT, ":encoding(sjis)");

which seems quite a bit simpler than Python.

Agreed, in isolation. But in my limited experience, and from reading http://perldoc.perl.org/functions/binmode.html ... I think you probably need to hold at least as many concepts in your head simultaneously to get it to work.

... The description of binmode() in "man perlfunc" sounds like encoding can be changed on-the-fly but my attempt to do so had no effect

which sort of belies simple

TCL appears to have on-the-fly encoding changes:

 | encoding system ?encoding?  | The system  encoding is used whenever Tcl passes strings | to system calls.  http://www.tcl.tk/man/tcl8.4/TclCmd/encoding.htm

So if you call rename, the system encoding is used for the filename, but does that mean it is used for sysout?

-jJ



More information about the Python-ideas mailing list