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


Groups > comp.lang.python > #100384

Re: codecs.StreamRecoder not doing what I expected.

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From "D'Arcy J.M. Cain" <darcy@VybeNetworks.com>
Newsgroups comp.lang.python
Subject Re: codecs.StreamRecoder not doing what I expected.
Date Sun, 13 Dec 2015 13:14:12 -0500
Organization Vybe Networks Inc.
Lines 51
Message-ID <mailman.213.1450030464.12405.python-list@python.org> (permalink)
References <20151212140113.78e3c945@imp> <n4i0er$48i$1@ger.gmane.org> <20151213013545.5a57388b@imp> <201512131217.tBDCHOO0027527@fido.openend.se>
Mime-Version 1.0
Content-Type text/plain; charset=US-ASCII
Content-Transfer-Encoding 7bit
X-Trace news.uni-berlin.de wcz8aIB5s4D2ny+66ilelgkggN0KpC84d2YIwP/EICxg==
Return-Path <darcy@VybeNetworks.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'sys': 0.05; 'encoding:': 0.07; 'cc:addr:python-list': 0.09; 'creighton': 0.09; 'utf8': 0.09; 'worked.': 0.09; 'python': 0.10; 'subject:not': 0.11; 'output': 0.13; 'apache': 0.14; 'encoding': 0.15; 'googling': 0.16; 'program?': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; "wouldn't": 0.16; 'config': 0.18; 'laura': 0.18; '>>>': 0.20; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'fix': 0.21; 'ascii': 0.22; 'cc:no real name:2**0': 0.22; 'dec': 0.23; 'this:': 0.23; 'import': 0.24; 'header:In-Reply-To:1': 0.24; "doesn't": 0.26; 'right.': 0.27; '+0100': 0.27; '-0500,': 0.29; 'subject:what': 0.29; 'asked': 0.29; 'print': 0.30; 'that.': 0.30; 'guess': 0.31; 'fixed': 0.31; "can't": 0.32; 'problem': 0.33; 'similar': 0.33; 'file': 0.34; 'add': 0.34; 'server': 0.34; "isn't": 0.35; 'but': 0.36; 'there': 0.36; 'subject:: ': 0.37; 'display': 0.37; 'charset:us-ascii': 0.37; 'log': 0.38; 'skip:p 20': 0.38; 'why': 0.39; 'sure': 0.39; 'some': 0.40; 'your': 0.60; 'default': 0.61; 'strange': 0.63; '>other': 0.84; 'expect.': 0.84; 'received:98.158': 0.84; 'subject:doing': 0.84; '646': 0.91
In-Reply-To <201512131217.tBDCHOO0027527@fido.openend.se>
X-Mailer Claws Mail 3.9.3 (GTK+ 2.24.23; x86_64-pc-linux-gnu)
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:100384

Show key headers only | View raw


On Sun, 13 Dec 2015 13:17:24 +0100
Laura Creighton <lac@openend.se> wrote:
> In a message of Sun, 13 Dec 2015 01:35:45 -0500, "D'Arcy J.M. Cain"
> writes:
> >When I try to print it to the web page it fails because the \xe9
> >character is not valid ASCII.  However, my default encoding is utf-8.
> >Other web pages on the same server display fine.
> >
> >I have the following in the Apache config by the way.
> >
> >SetEnv PYTHONIOENCODING utf8
> >
> >So, my file is utf-8, I am reading it as utf-8, my Apache server
> >output is set to utf-8.  How is ASCII sneaking in?
> 
> What is your sys.stdout.encoding ?
> 
> just import sys and print the thing.
> 
> I think you will find that it is not what you expect.
> 
> Laura
> 

>>> print(sys.stdout.encoding)
utf8

That's what I was expecting.  However when I add that to my web log
output I get this:

get_recipe() PYTHONIOENCODING:  None
get_recipe() encoding:  646

Dang!  I was sure that I fixed that.  I have this in my Apache
configuration:

SetEnv PYTHONIOENCODING utf8

I guess I have an Apache problem now, not a Python one.  The strange
thing is that this was a fix for a similar problem I asked about and it
worked.  Isn't there some way that I can just set the default encoding
to utf8 for every Python program?  Googling suggests that I can't do
that but that doesn't see right.

Since utf8 includes ASCII why wouldn't it be the default anyway?

-- 
D'Arcy J.M. Cain
Vybe Networks Inc.
http://www.VybeNetworks.com/
IM:darcy@Vex.Net VoIP: sip:darcy@VybeNetworks.com

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


Thread

Re: codecs.StreamRecoder not doing what I expected. "D'Arcy J.M. Cain" <darcy@VybeNetworks.com> - 2015-12-13 13:14 -0500

csiph-web