I have a string which I encoded with python urllib2.quote(). The string in question is "Z%C3%BCrich", which was encoded from "Zürich". However, there seems to be a discrepancy between the way python handles this and the way JavaScript does.
In python:
>>> print urllib2.unquote("Z%C3%BCrich") Zürich In JavaScript:
> unescape("Z%C3%BCrich") 'Zürich' These are taking in the same input string, but producing very different output strings. What am I doing wrong?
Note: This post is not a duplicate of this post, in which the author had the opposite problem.
decodeURI("Z%C3%BCrich").urllib2.quote()is more likeencodeURI()in JavaScript. Andurllib2.unquote()isdecodeURI()rahter thanunescape(). You should always avoidescape()andunescape()function in JavaScript because they'll give you weird output...like you're getting now.