URL - URL encoding (Percent-encoding)

> (World Wide) Web - (W3|WWW) > (Web|Internet) - Resource

1 - About

Percent-encoding, also known as URL encoding, is a mechanism for encoding information in a Uniform Resource Identifier (URI).

Purpose:

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

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

Advertising

3 - Snippet

var uri = "sftp://hotitem\\gerard:Pwd#[email protected]:port";
console.log("The encoded URI is: "+encodeURI(uri));

The # must normaly be encoded as %23

4 - 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
Advertising

5 - Documentation / Reference

web/resource/encoding.txt · Last modified: 2019/04/27 22:36 by gerardnico