[prev in list] [next in list] [prev in thread] [next in thread] 

List:       httpclient-users
Subject:    Re: Best way to unescape encoded URLs
From:       Oleg Kalnichevski <olegk () apache ! org>
Date:       2009-01-12 13:44:37
Message-ID: 1231767877.5995.3.camel () ubuntu
[Download RAW message or body]

On Mon, 2009-01-12 at 11:52 +0000, Paul Taylor wrote:
> Peter Voss wrote:
> > Hi Bill,
> >
> > you could use java.net.URLDecoder. First extract the part of your 
> > string that has to be decoded. Then call:
> > URLDecoder.decode(encodedString, "UTF-8");
> >
> > e.g.
> > URLDecoder.decode("http%3A%2F%2Fwww.google.com%2F", "UTF-8")
> > will return
> > http://www.google.com/
> >
> Im not sure this is right because URLencoder/Decoder is for form url 
> encoding which is slighty different
> 
> I think you should the uri class instead
> 
>  URI uri = new URI("http", 
> "localhost",proxy/http%3A%2F%2Fwww.google.com%2F ,null);
>  return uri.toString();
> 
> this allows you to pass the whole string , you dont need to extract 
> parts of the String. Note the 4th null parameter, you need this if you 
> use the 3 parameter constrcutor it wont work
> 
> 
> Paul
> 

You might also want to take a look at Commons Codec.

http://commons.apache.org/

Oleg 

> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic