Percent-encoding Reserved Characters
When a character from the reserved set (a "reserved character") has special meaning (a "reserved purpose") in a certain context, and a URI scheme says that it is necessary to use that character for some other purpose, then the character must be percent-encoded. Percent-encoding a reserved character involves converting the character to its corresponding byte value in ASCII and then representing that value as a pair of hexadecimal digits. The digits, preceded by a percent sign ("%
") which is used as an escape character, are then used in the URI in place of the reserved character. (For a non-ASCII character, it is typically converted to its byte sequence in UTF-8, and then each byte value is represented as above.)
The reserved character "/
", for example, if used in the "path" component of a URI, has the special meaning of being a delimiter between path segments. If, according to a given URI scheme, "/
" needs to be in a path segment, then the three characters "%2F
" or "%2f
" must be used in the segment instead of a raw "/
".
! |
# |
$ |
& |
' |
( |
) |
* |
+ |
, |
/ |
: |
; |
= |
? |
@ |
[ |
] |
%21 |
%23 |
%24 |
%26 |
%27 |
%28 |
%29 |
%2A |
%2B |
%2C |
%2F |
%3A |
%3B |
%3D |
%3F |
%40 |
%5B |
%5D |
Reserved characters that have no reserved purpose in a particular context may also be percent-encoded but are not semantically different from those that are not.
In the "query" component of a URI (the part after a ? character), for example, "/
" is still considered a reserved character but it normally has no reserved purpose, unless a particular URI scheme says otherwise. The character does not need to be percent-encoded when it has no reserved purpose.
URIs that differ only by whether a reserved character is percent-encoded or appears literally are normally considered not equivalent (denoting the same resource) unless it can be determined that the reserved characters in question have no reserved purpose. This determination is dependent upon the rules established for reserved characters by individual URI schemes.
Read more about this topic: Percent-encoding, Percent-encoding in A URI
Famous quotes containing the words reserved and/or characters:
“We know of no scripture which records the pure benignity of the gods on a New England winter night. Their praises have never been sung, only their wrath deprecated. The best scripture, after all, records but a meagre faith. Its saints live reserved and austere. Let a brave, devout man spend the year in the woods of Maine or Labrador, and see if the Hebrew Scriptures speak adequately to his condition and experience.”
—Henry David Thoreau (18171862)
“The Nature of Familiar Letters, written, as it were, to the Moment, while the Heart is agitated by Hopes and Fears, on Events undecided, must plead an Excuse for the Bulk of a Collection of this Kind. Mere Facts and Characters might be comprised in a much smaller Compass: But, would they be equally interesting?”
—Samuel Richardson (16891761)