Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #33725

Re: Encoding conundrum

From Nobody <nobody@nowhere.com>
Subject Re: Encoding conundrum
Date 2012-11-21 12:18 +0000
Message-Id <pan.2012.11.21.12.18.23.439000@nowhere.com>
Newsgroups comp.lang.python
References <CADNxFdMV857vQkHy9+kfF=dA5hOX+aNNNqXLMtiJzT_deXk66A@mail.gmail.com> <mailman.115.1353452627.29569.python-list@python.org> <6cce1b50-aa37-4077-89d5-34e57de2193e@googlegroups.com>
Organization Zen Internet

Show all headers | View raw


On Wed, 21 Nov 2012 03:24:01 -0800, danielk wrote:

>> >>> import sys
>> >>> sys.stdout.encoding
>> 'cp437'
>
> Hmmm. So THAT'S why I am only able to use 'cp437'. I had (mistakenly)
> thought that I could just indicate whatever encoding I wanted, as long as
> the codec supported it.

sys.stdout.encoding determines how Python converts unicode characters
written to sys.stdout to bytes.

If you want the correct characters to be shown, this has to match the
encoding which the console window uses to convert those bytes back to
unicode characters.

You can tell Python to use whichever encoding you want, but often you only
get to control one side of the equation, in which case there's only one
"right" answer.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Encoding conundrum Ian Kelly <ian.g.kelly@gmail.com> - 2012-11-20 16:03 -0700
  Re: Encoding conundrum danielk <danielkleinad@gmail.com> - 2012-11-21 03:24 -0800
    Re: Encoding conundrum Nobody <nobody@nowhere.com> - 2012-11-21 12:18 +0000
    Re: Encoding conundrum Dave Angel <d@davea.name> - 2012-11-21 08:02 -0500
  Re: Encoding conundrum danielk <danielkleinad@gmail.com> - 2012-11-21 03:24 -0800

csiph-web