Mobile app version of vmapp.org
Login or Join
Si4351233

: What is the meaning and use case of each URL encoding Reserved Characters Quote from Percent-encoding When a character from the reserved set (a "reserved character") has special meaning

@Si4351233

Posted in: #Http #Url #UrlEncoding #UrlParameters

Quote from Percent-encoding


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


What does each of this characters mean in context of an URI?



with a search engine I didn't find a list and their meanings/use case.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Si4351233

1 Comments

Sorted by latest first Latest Oldest Best

 

@Ann8826881

What does each of this characters mean in context of an URI?


Note that a URI consists of several different "contexts" or parts. eg. the scheme, host, URL-path, query string and fragment identifier. Whether a reserved character has special meaning is dependent on where in the URL that character is used. These "reserved characters" are often used to delimit parts of the URI. You only need to encode these characters if they conflict with the "special meaning" (if any).

Some characters are simply defined as possible alternatives to others, so might not carry any special meaning (on the server) where it is processed.

I'll start the ball rolling, some I'm not sure about:


! (Exclamation Mark) - not sure. JavaScript does not encode this character. It has historically been used to represent AJAX URLs in the fragment identifier. eg. #! (hash-bang) - but this was Google, not a "standard".
# (Hash / Pound) - Delimits the fragment identifier. (Last part of the URL, client-side only, not passed to the server.)
$ (Dollar) - Not sure. No special meaning in the URL-path or query string that I am aware of. However, JavaScript's encodeURIComponent() will encode this character (whereas encodeURI() does not) which implies it might have special meaning in the query string.
& (Ampersand) - Used to delimit query string parameters.
' (Apostrophe / Single quote) - Not sure. No special meaning in the URL-path or query string. JavaScript does not encode this character.
( and ) (Parentheses / Brackets) - Not sure. No special meaning in the URL-path or query string. JavaScript does not encode these characters.
* (Asterisk) - Not sure. No special meaning in the URL-path or query string. JavaScript does not encode this character.
+ (Plus) - Can be used to encode a space (alternative to %20) in the query string only. A literal + when used in the URL-path.
, (Comma) - An alternative to ;.
/ (Slash) - Delimits path segments in the URL-path.
: (Colon) - Delimits the scheme from the host and host from the port.
; (Semicolon) - Delimits URL parameters in the query string.
= (Equals) - Delimits name/value pairs in the query string.
? (Question Mark) - Delimits the start of the query string. @ (At) - Delimits userinfo in the authority part of the URL.
[ and ] (Square Brackets) - Note sure. These are used by PHP to allow array-like parameter names in the query string - although I don't think this is the "official" use.


Just to note the differences between PHP (urlencode() and rawurlencode()) and JavaScript (encodeURIComponent() and encodeURI() respectively) when using the built-in functions to encode parts of the URL... PHP encodes all "reserved" characters, however, JavaScript (in the browser) is far more selective.

Further reference:
RFC 3986 - Uniform Resource Identifier (URI): Generic Syntax

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme