Bny
Bny

Reputation: 21

Javascript + python url-en/decoding problem

Hi there im kinda stucked with the url encoding between python and javascript, i hope you can help me out :S

Javascript:

encodeURIComponent('lôl');
-> "l%C3%B4l"

Python:

import urllib
test = container.REQUEST.form.get('test')
print test
print urllib.unquote(test)
-> "lÃŽl"
-> "lÃŽl"

Javascript encodes "lôl" twice however python does that once with it, i dunno how to escape from there because i receive anyway throgh the Prototype HTTP GET request "l%C3%B4l" instead of "l%F4l"

Best Regards Bny

**edit its on a zope webserver

Upvotes: 2

Views: 2289

Answers (1)

nosklo
nosklo

Reputation: 222792

zope already url-decodes it - issue is that you're getting a utf-8 bytestring and printing it on a non-utf-8 terminal. Try decoding the string.

x = 'l\xc3\xb4l'
unicode_x = x.decode('utf-8')
print unicode_x

Upvotes: 1

Related Questions