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.

From "D'Arcy J.M. Cain" <darcy@VybeNetworks.com>
Newsgroups comp.lang.python
Subject Re: codecs.StreamRecoder not doing what I expected.
Date 2015-12-13 13:14 -0500
Organization Vybe Networks Inc.
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>

Show all headers | 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