hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: Best way to unescape encoded URLs
Date Mon, 12 Jan 2009 13:44:37 GMT
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


Mime
View raw message