[X]

escape and unescape

browser tricks 1996 partly

The original URL encoders. escape turned characters above Latin-1 into %uXXXX sequences that no other system on earth understood.

In 2026: Partly. Both functions still exist, Annex B again, and still work on plain ASCII. But escape predates UTF-8 URLs: anything beyond Latin-1 becomes %u sequences that were never standard, so servers, other languages and encodeURIComponent all refuse to decode them. Every %u2026 littering an old guestbook traces back to this pair.

Where it came from: JavaScript 1.0, Netscape 2, 1996. Superseded by encodeURIComponent in ECMAScript 3, 1999. MDN

<script language="JavaScript">
var s = "café & 100% niño";

document.write("<p>escape():            " + escape(s) + "</p>");
document.write("<p>encodeURIComponent(): " + encodeURIComponent(s) + "</p>");

// And the party trick nothing else can decode:
document.write("<p>escape('\\u65e5\\u672c\\u8a9e') gives " +
               escape("日本語") + "</p>");
</script>
sandboxed demo · breaks nothing but itselfrestart

More in browser tricks

all 25 in browser tricks › · the whole library ›