2

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

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks alot that worked well but how can i merge now that unicode string (with especially chars) with my normal string? i receive always and "UnicodeEncodeError" :S
@Bny: decode your normal string too. Use only unicode all over the place. If you're defining the string on the code, use u'foo' literal syntax.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.