URL Encode and Decode
Percent-Encoding - URL encoding
Percent-Encoding or URL encoding is a mechanism for encoding information in URI, currently defined in RFC3986. It is mainly used to encode data sent by a GET query in a URL. It owes its name to the fact that a given byte starts with a percentage sign after encoding. The encoding of a byte consists of converting it into a two-digit hexadecimal value stored in ASCII and preceded by a percentage (i.e. each encoded byte is written with three characters).
Characters A to Z, a to z, 0 to 9, and '-', '_', '.', '~' are allowed in the URL. These are unreserved characters:
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9 - _ . ~
The second group of characters are reserved characters and must only be encoded under certain circumstances.
Reserved characters are: ! * ' ( ) ; : @ & = + $ , / ? # [ ]
# | character | encoded |
---|---|---|
1 | ! | %21 |
2 | # | %23 |
3 | $ | %24 |
4 | ' | %27 |
5 | ( | %28 |
6 | ) | %29 |
7 | * | %2A |
8 | + | %2B |
9 | , | %2C |
10 | / | %2F |
11 | : | %3A |
12 | ; | %3B |
13 | = | %3D |
14 | ? | %3F |
15 | @ | %40 |
16 | [ | %5B |
17 | ] | %5D |