While developing in Python for Google Appengine you’ll might want to encode or decode URLs. Sounds like a simple task, as it is in many other languages. Somehow in Python 2.5.x which is the version supported by appengine, it’s not as straight forward, at least it wasn’t for me. There are tones solutions, suggestions and examples out there, not all work as expected.
After some trial and error it finally worked:
import urllib text = 'some text' #decodeURI text = urllib.unquote(text.encode('ascii')).decode('utf-8') #encodeURI text = urllib.quote(text.encode('utf-8'))
Might spare you some time.