Query string: Difference between revisions

Content deleted Content added
Syntax: rewrite
Line 27:
For each [[Field (computer science)|field]] of the form, the query string contains a pair parameter=value. Web forms may include fields that are not visible to the user, and these fields are included in the query string when the form is submitted.
 
== [[URL Encoding]] ==
[[space (punctuation)|Space]]s, [[ampersand]]s, [[equal sign]]s, and many other characters could cause trouble with the URL and the query string.
Therefore the value in each parameter-value pair is [[URL Encoding|URL-Encoded]]. This is a process by which each of these troublesome characters is converted into a numeric representation.
 
The parameter=value pairs in the query string are encoded according to a schema known as [[URL Encoding]]. This is necessary because some characters cannot be part of a URL (for example, the space) and some other characters have a special meaning in a URL (for example, the character <code>#</code>, which is used to locate a point within a page).
'%2D' is one such example.
* The percent sign signals the start of such a string.
* '2D' is the number 45 in [[Hexidecimal|HEX]] - ''in [[ASCII]] and [[UNICODE]], each character has a numerical index.''
Therefore, %2D is the minus sign, and %25 is the percent character.
 
In particular, [[RFC 1738]] specifies that &ldquo;only alphanumerics, the special characters "$-_.+!*'(),", and reserved characters used for their reserved purposes may be used unencoded within a URL&rdquo;. All characters in a query string can be replaced by their hexadecimal value precedeed by the symbol <code>%</code>. For example, the equal sign can be replaced by <code>%3D</code>. All characters can be replaced this way; for the characters that are forbidden in a query string, this is not only possible but necessary.
=== Quirks ===
 
* Spaces are converted to plus signs, ''e.g. "hello there" would be converted to hello+there. ''
The space character can be also represented by <code>+</code>.
* from rfc 1738: "Thus, only alphanumerics, the special characters "$-_.+!*'(),", and reserved characters used for their reserved purposes may be used unencoded within a URL." This seems to say that "-" is permitted unencoded, and infact the javascript function escape() supports this.
 
== See also ==