Differences between encodeURI, encodeURIComponent, and escape: upper ASCII characters (codes 128-255)

JavaScript FAQ | Strings & RegExp FAQ | URL-encoding  

As shown in the table below,

encodeURI
,
encodeURIComponent
, and
escape
produce different results for upper ASCII characters. For example, the non-breaking space character (ASCII-code 0xA0, or 160) will be encoded as
%A0
if you use
escape
, and
%C2%A0
if you use
encodeURI
or
encodeURIComponent
. The small ü or u-umlaut letter (ASCII-code 0xFC, or 252) will be encoded as
%FC
if you use
escape
, and
%C3%BC
if you use
encodeURI
or
encodeURIComponent
. (See also tables for lower ASCII and Unicode characters.)
chr    escape(chr)   encodeURI(chr)  encodeURIComponent(chr)

Copyright © 1996-2018, JavascriptFAQ.net.