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?
views:
62answers:
4
                
                A: 
                
                
              
            Use the unescape() function, eg:
alert(unescape("%2Fu%2F2069290%2F"));
                  Mike Anchor
                   2010-02-02 18:03:17
                
              
                +5 
                A: 
                
                
              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"));
                  Johan Dahlin
                   2010-02-02 18:05:53
                
              +1 For the additional information about `unescape` and `decodeURIComponent`.
                  Gumbo
                   2010-02-02 18:11:54
                unescape/escape are DOM functions (but not part of any spec) that are supported by some browsers to varying degrees (https://developer.mozilla.org/en/DOM/window.unescape). At least in TraceMonkey, escaping/unescaping non-latin1 codes works fine.decodeURIComponent/encodeURIComponent are core javascript functions supported by all javascript engines, including the engines in browsers (http://www.w3schools.com/jsref/jsref_decodeuricomponent.asp). So best to stick with Johan and Darin's answers.
                  DaveS
                   2010-02-02 18:52:47