Alex Rivera | Logout

Encode URL query parameters

Asked 2011-06-01T09:21:04.310
15

How can I encode URL query parameter values? I need to replace spaces with %20, accents, non-ASCII characters etc.

I tried to use URLEncoder but it also encodes / character and if I give a string encoded with URLEncoder to the URL constructor I get a MalformedURLException (no protocol).

Edit
Report

1 Answer

3

So what you're saying is that you want to encode part of your URL but not the whole thing. Sounds to me like you'll have to break it up into parts, pass the ones that you want encoded through the encoder, and re-assemble it to get your whole URL.

answered 2011-06-01T09:23:25.570

Your Answer