Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #100384 > unrolled thread
| Started by | "D'Arcy J.M. Cain" <darcy@VybeNetworks.com> |
|---|---|
| First post | 2015-12-13 13:14 -0500 |
| Last post | 2015-12-13 13:14 -0500 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: codecs.StreamRecoder not doing what I expected. "D'Arcy J.M. Cain" <darcy@VybeNetworks.com> - 2015-12-13 13:14 -0500
| From | "D'Arcy J.M. Cain" <darcy@VybeNetworks.com> |
|---|---|
| Date | 2015-12-13 13:14 -0500 |
| Subject | Re: codecs.StreamRecoder not doing what I expected. |
| Message-ID | <mailman.213.1450030464.12405.python-list@python.org> |
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 top | Article view | comp.lang.python
csiph-web