Hi,
Try this solution.
Create a script named sitecustomize.py into your
python lib directory (i.e /usr/lib/python2.3) and add
the following code :
#-----------sitecustomize.py---
import sys
sys.setdefaultencoding('latin-1')
See u,
Lja
--- BRINER Cedric <[EMAIL PROTECTED]> wrote:
> python-2.3 apache2
> hi,
>
> I'm trying to use unicode function into a cgi script
> with no success.
> #-------- cedric.py---
> #!/usr/bin/python
> import os,sys
> import cgi
> import cgitb; cgitb.enable()
> print "Content-Type: text/html\
> "+os.linesep+"\
> "+os.linesep+"<TITLE>hipo'potame</TITLE>"
> sys.stdout.flush()
> content = u'c\xe9dric'
> print content
> #---------------------
>
> when I invoke it from my xterm, I get:
> > python cedric.py
> Content-Type: text/html
>
> <TITLE>hipo'potame</TITLE>
> c�dric
>
> but the same does not work on apache:
>
>
> /home/system/briner/obsadminwww/cedric.py
> 6 "+os.linesep+"\
>
> 7 "+os.linesep+"<TITLE>hipo'potame</TITLE>"
>
> 8 sys.stdout.flush()
>
> 9 content = u'c\xe9dric'
>
> 10 print content
>
> content = u'c\xe9dric'
>
> UnicodeEncodeError: 'ascii' codec can't encode
> character u'\xe9' in
> position 1: ordinal not in range(128)
> args = ('ascii', u'c\xe9dric', 1, 2, 'ordinal
> not in range(128)')
> encoding = 'ascii'
> end = 2
> object = u'c\xe9dric'
> reason = 'ordinal not in range(128)'
> start = 1
>
> As if the stdout as to pbe in ascii??
>
> any idea on how to do this
>
> Cedric BRINER
>
> _______________________________________________
> Tutor maillist - [email protected]
> http://mail.python.org/mailman/listinfo/tutor
>
D�couvrez nos promotions exclusives "destination de la Tunisie, du Maroc, des
Bal�ares et la R�p. Dominicaine sur Yahoo! Voyages :
http://fr.travel.yahoo.com/promotions/mar14.html
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor