Reputation: 26227
I have a string such as "%2Fu%2F2069290%2F"
in JavaScript (extracted from a web page). How do I get the human-readable version of that string?
Upvotes: 5
Views: 2057
Reputation: 26546
Short version: Use decodeURIComponent()
.
Longer version: In older versions of JavaScript you could use unescape()
but that has been deprecated since it only works properly for the LATIN1/ISO8859-1 codeset, so you really want to use decodeURIComponent()
which is supported by all modern browsers.
var c = decodeURIComponent("%2Fu%2F2069290%2F"));
Upvotes: 7
Reputation: 666
Use the unescape()
function, eg:
alert(unescape("%2Fu%2F2069290%2F"));
Upvotes: 0