top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is URL Encoding and URL Decoding ?

+3 votes
298 views
What is URL Encoding and URL Decoding ?
posted Feb 25, 2015 by Dominic

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote
 
Best answer

URL ENCODING:

The URL encoding procedure is responsible for replacing all the spaces and every other extra special character of a URL, into their corresponding Hex representation.

URLEncoder should be the way to go. You only need to keep in mind to encode only the individual query string parameter name and/or value, not the entire URL, for sure not the query string parameter separator character & nor the parameter name-value separator character =.

 String url = "http://example.com/query?q=" + URLEncoder.encode("random word £500 bank $", "UTF-8");

Note that spaces in query parameters are represented by +, not %20, which is legitimately valid. The %20 is usually to be used to represent spaces in URI itself (the part before the URI-query string separator character ?), not in query string (the part after ?).

URL DECODING:

The URL decoding is the exact opposite procedure.

answer Feb 26, 2015 by Karthick.c
...