hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Taylor <paul_t...@fastmail.fm>
Subject Re: Best way to unescape encoded URLs
Date Mon, 12 Jan 2009 11:52:41 GMT
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

---------------------------------------------------------------------
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