Table of Contents

About

In a URL / Uniform Resource Identifier (URI), you have reserved character that are part of the URL syntax that cannot be used.

For instance:

Percent-encoding, also known as Url Encoding maps (ie encode) :

  • this reserved characters
  • to text that starts with a percent (hence percent encoding)

Example:

Url Encoding Set Illustration

Although it is known as URL encoding it is, in fact, used more generally within the main Uniform Resource Identifier (URI) set, which includes both:

It is also used in the preparation of data of the application/x-www-form-urlencoded media type, as is often used in the submission of HTML form data

Purpose

The purpose detailed is:

  • protecting characters from being interpreted as special/reserved URL delimiters,
  • protecting URLs from being mangled by transmission media with character conversions (like some email systems).

Snippet

let uri = "sftp://hostname\\foo:Pwd#Pwd@host:port";
console.log("The encoded URI is: "+encodeURI(uri));

The # must normaly be encoded as %23

Reserved Character

Character URL Encoding
Reserved
! %21
# %23
$ %24
& %26
' %27
( %28
) %29
* %2A
+ %2B
, %2C
/ %2F
: %3A
; %3B
= %3D
? %3F
@ %40
[ %5B
] %5D
Common characters
newline %0A or %0D or %0D%0A
space %20
" %22
% %25
- %2D
. %2E
< %3C
> %3E
\ %5C
^ %5E
_ %5F
` %60
{ %7B
| %7C
} %7D
~ %7E

1) 2)