Difference between URL.decode and URL.decodeComponent

74 views
Skip to first unread message

Kady

unread,
Sep 10, 2010, 12:00:25 PM9/10/10
to Google Web Toolkit
What is the difference between URL.decode and URL.decodeComponent
methods ? Any example is appreciated.

Thank you.

Thomas Broyer

unread,
Sep 10, 2010, 7:50:36 PM9/10/10
to Google Web Toolkit


On Sep 10, 6:00 pm, Kady <kaushika...@gmail.com> wrote:
> What is the difference between URL.decode and URL.decodeComponent
> methods ? Any example is appreciated.

The exact same difference as between decodeURI and decodeURIComponent
in plain old JS:
https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/decodeURI
https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/decodeURIComponent
http://stackoverflow.com/questions/747641/what-is-the-difference-between-decodeuricomponent-and-decodeuri
http://livedocs.adobe.com/flex/3/langref/package.html#decodeURI()
(ActionScript 3 is an extension of ECMAScript)

lineman78

unread,
Sep 10, 2010, 10:10:59 PM9/10/10
to Google Web Toolkit
decode and encode component is intended to be used in parts of the
query. Take the following url for example:

http://www.google.com/search?q=fox%26hound
|___________| <
component

The bigggest difference between encode and encodeComponent is what
special chars it will encode. Notice above %26, which is an
ampersand. This will only be encoded with encodeComponent, not
encode.
Reply all
Reply to author
Forward
0 new messages