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?
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"));
alert(decodeURIComponent("%2Fu%2F2069290%2F"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With