I have the following variable:
var string="Mazatl%E1n";
The string is returned like that by the server. All I want to do is decode that into: Mazatlán
. I've tried the following:
var string="Mazatl%E1n";
alert(unescape(string));
alert(decodeURI(string));
unescape works fine but I don't want to use it because I understand it is deprecated, instead I tried decodeURI which fails with the following error:
Uncaught URIError: URI malformed
Why ? Any help is appreciated.
var string="Mazatl%E1n";
alert(unescape(string));
alert(decodeURI(string));
decodeURIComponent
...escape()
andunescape()
are defined for ISO strings.decodeURI()
andencodeURI()
are defined for UTF-8 strings.encodeURIComponent("Mazatlán")