Re: write Unicode to sys.out.write without access to sitecustomize.py

2009-08-28 Thread exarkun

On 02:51 pm, rk...@pobox.com wrote:


I would like to tell the system that it's OK to write Unicode to 
sys.out
and sys.err.  However, I'm doing this in a CGI script where I don't 
have

access to the system directories, and as such can't use
sys.setdefaultencoding in sitecustomize.py.

Is there a way to make this happen?


Sure, just replace the two files with versions that know how to encode 
the unicode using the correct encoding:


import sys, codecs
info = codecs.lookup('utf-8') # for example
sys.stdout = info.streamwriter(sys.stdout)
sys.stderr = info.streamwriter(sys.stderr)

Jean-Paul
--
http://mail.python.org/mailman/listinfo/python-list


write Unicode to sys.out.write without access to sitecustomize.py

2009-08-28 Thread Rob Knop

I would like to tell the system that it's OK to write Unicode to sys.out
and sys.err.  However, I'm doing this in a CGI script where I don't have
access to the system directories, and as such can't use
sys.setdefaultencoding in sitecustomize.py.

Is there a way to make this happen?

-- 
--Rob Knop
  E-mail:rk...@pobox.com
  Home Page: http://www.pobox.com/~rknop/
  Blog:  http://www.sonic.net/~rknop/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list