cgi.FieldStorage translating unicode strangely

Posted by trydyingtolive on Stack Overflow See other posts from Stack Overflow or by trydyingtolive
Published on 2010-03-09T03:17:56Z Indexed on 2010/03/09 3:21 UTC
Read the original article Hit count: 398

Filed under:
|
|
|

I have a form that is on a UTF-8 encoded page. When I submit the form cgi.FieldStorage converts any non-ascii character to an odd format.

For example if I submit the value c. The browser will send %c4%87. I want to convert that to the string \xc4\x87. However, cgi.FieldStorage is converting it to \\xc4\\x87.

post = cgi.FieldStorage(fp=env['wsgi.input'],
                            environ=env,
                            keep_blank_values=True)

Python 2.6 on Ubuntu 9.10SE, Apache2, mod_wsgi.

© Stack Overflow or respective owner

Related posts about python

Related posts about cgi