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


Groups > comp.lang.python > #33725

Re: Encoding conundrum

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!zen.net.uk!dedekind.zen.co.uk!reader02.nrc01.news.zen.net.uk.POSTED!not-for-mail
From Nobody <nobody@nowhere.com>
Subject Re: Encoding conundrum
Date Wed, 21 Nov 2012 12:18:23 +0000
User-Agent Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity.)
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>
MIME-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 8bit
Lines 21
Organization Zen Internet
NNTP-Posting-Host 6f549b8d.news.zen.co.uk
X-Trace DXC=J_>7F<Q12No6l^Oa0Ah_Pg]G;bfYi23hd=dR0\ckLKG`WeZ<[7LZNRf]>XigF\nX>lNQ<`Sf8^Tao8RRH8d=PK;lKnm1C7>@g5d
X-Complaints-To abuse@zen.co.uk
Xref csiph.com comp.lang.python:33725

Show key headers only | 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