code.youlikeshare.com
The url encoding is required when you are trying to programatically assign parameters onto an URL for query, page redirection and so on. So, what's the different between the urlencode and rawurlencode?

From the output point of view, both urlencode and rawurlencode returns the same result except
  • urlencode encode space character into + (plus), but rawurlencode encode the space character into %20.
  • urlencode encode ~ into %7E, but rawurlencode didn't percent-encode this character.
Both the urlencode and rawurlencode will percent-encode the reserve characters by replacing them with % followed by 2 hex digits. Below please find the table of reserved and unreserved characters:
Reserved Characters : / ? # [ ] @ ! $ & ' ( ) * + , ; =
Unreserved Characters alpha digits - . _ ~
Note: The ~(tildes) will be percent-encoded by urlencode. Please see the above description.

Below please find the value of percent-encoded for the reserved characters:

CharEncoded CharEncoded CharEncoded CharEncoded
:%3A /%2F ?%3F #%23
[%5B ]%5D @%40 !%21
$%24 &%26 '%27 (%28
)%29 *%2A +%2B ,%2C
;%3B =%3D  

When should I use the urlencode or rawurlencode? It's depends on the usage, but I will recommend the use of rawurlencode for the url encoding with no query string, and urlencode to encode particularly for the query string (after the ?). It is due to the percent-encoded of application/x-www-form-urlencoded media type for urlencode.

Try it yourself:
Enter your text for encoding: