user1886965
user1886965

Reputation: 51

Python URL decoding?

In javascript I do the following:

encodeURIComponent(comments)

while in Python i do the following:

urllib2.unquote(comments)

For some reason, when I do the following:

encodedURIComponents('ø')

I get %C3%B8, but when I decode

urllib2.unquote('%C3%B8')

I get ø instead of ø, which is the original character.

What gives?

I'm on a platform that uses jQuery on client side, and Python/Django server side.

Upvotes: 5

Views: 906

Answers (1)

VisioN
VisioN

Reputation: 145368

Simply try to decode it:

urllib2.unquote('%C3%B8').decode('utf-8')   # --> 'ø'

Upvotes: 7

Related Questions