Reputation: 409
Is there some plug-in or library to encode and decode URLs?
For example im doing that:
name='Jazmín Fernández'
self.redirect('/page?userName='+name)
But, obviously there are some characters that need to be encoded (í, á, and the space between n and F). So, this give me an error.
Thanks!!!
Upvotes: 0
Views: 492
Reputation: 56
You should convert your unicode string to UTF8, before passing it to urllib.urlencode.
>>> name = u'Jazmín Fernández'
>>> urllib.urlencode({'name': name.encode('utf8')})
'name=Jazm%C3%ADn+Fern%C3%A1ndez'
Upvotes: 3