URL encoding, also known as percentage encoding, is a method of encoding data in
URL addresses, so that even if the data contains special characters, it can still
be sent as part of the URL.
For example, if you want to send the '#' character as part of the path address
or of your querystring, this will not work - because the '#' character has a
very special meaning in the interpretation of URLs. Therefore, you need to
encode the character so that it can be sent along - but without being
'misunderstood' by the server and client respectively.
Specifically, '#' is translated to '%23'.
This type of encoding of data is defined via
RFC 3986.
A total of 18 reserved characters are defined that must be translated before
they can be sent as via querystring, or as part of the
address itself: ": / ? # [ ] @ ! $ & ' ( ) * + , ; =". Additionally, all
non-US-ASCII characters and space must be encoded as well.
The URLencode/URLdecode tool offers a quick and easy online tool for this.
During the development of a website, developers have lots of built-in
functions that can do that, but sometimes, you just need a quick encoding/decoding
without having to write code. That's where this tool comes into its own ;)
Selected code functions that can do this:
-
Javascript: encodeURI(), escape(), encodeURIComponent(), decodeURI(), unescape() and decodeURIComponent().
-
PHP: urlencode(), rawurlencode(), urldecode() and rawurldecode().
-
C#: System.Web.HttpUtility.UrlEncode() and System.Web.HttpUtility.UrlDecode()
Samples
Try out these, if you would like to give it a go, and see how it works:
URLEncode: Hello wørld!
URLEncode: this is several $pecial chars @ once!
URLDecode: this+is+several+%24pecial+chars+%40+once!