Is there an equivalent for encodeURIComponent in Java?
Is there an equivalent for encodeURIComponent in Java?
Do you think you could explain in detail what it does or give a link to some documentation of this function? It would make it much easier for people to answer your question.
encodeURIComponent is a JavaScript URI Encoding function.
See:
http://msdn.microsoft.com/library/de...icomponent.asp
I'm not sure about the subtle differences between URI and URL. But I think URLEncoder.encode(String) is roughly what you want.
<http://java.sun.com/j2se/1.4.2/docs/api/java/net/URLEncoder.html#encode(java.lang.String)>
Since I'm UTF-8, I will add that URLEncoder.encode(x, "UTF-8") will ensure all non-ASCII characters are also escaped in byte pairs (see http://www.w3.org/TR/html40/appendix...on-ascii-chars.
After many hours of pondering this character set problem () I discovered that the standard is and doesn't allow character sets other than US-ASCII in the URL. So the above way is the defacto standard.
That is all, time for the
Bookmarks