Percent-encoding - Percent-encoding in A URI - Percent-encoding Reserved Characters

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 "/".

Reserved characters after percent-encoding
! # $ & ' ( ) * + , / : ; = ? @ [ ]
%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:

    The planet on which we live is poorly organized, many areas are overpopulated, others are reserved for a few, technology’s potential is only in part realized, and most people are starving.
    Friedrich Dürrenmatt (1921–1990)

    Of all the characters I have known, perhaps Walden wears best, and best preserves its purity. Many men have been likened to it, but few deserve that honor. Though the woodchoppers have laid bare first this shore and then that, and the Irish have built their sties by it, and the railroad has infringed on its border, and the ice-men have skimmed it once, it is itself unchanged, the same water which my youthful eyes fell on; all the change is in me.
    Henry David Thoreau (1817–1862)