[Tutor] unicode type on cgi script

Kent Johnson kent37 at tds.net
Tue Mar 15 15:49:43 CET 2005


BRINER Cedric wrote:
>>print uses sys.stdout.encoding to encode unicode strings. You can check what this is in your cgi with
>>import sys
>>print sys.stdout.encoding
> 
> didn't know
> 
>>I think it will work to explicitly encode the unicode string in the encoding you want for the web 
>>page. Try
>>print content.encode(xxx)
> 
> did and worked !
> 
>>where xxx is the encoding you want, for example 'utf-8' or 'latin-1'.
> 
> perfect.
> the funny thing is that now , it perfeclty works on the cgi side but not
> anymore on my uxterm.

What encoding did you use in the cgi? Is it the same as sys.stdout.encoding in uxterm?

Kent




More information about the Tutor mailing list