A Techno Blog, mainly about Java

escaping characters

I find that if you are using HTTP GET you will run into a lot of troubles with your url string with characters such as quotes, colons, and others. The way to get around that is to use HTTP POST. But, if you still want to use GET, the best way is to escape the characters.

“URL encoding is the practice of translating unprintable characters or characters with special meaning within URLs to a representation that is unambiguous and universally accepted by web browsers and servers”

Here are a few javascript solutions on how to encode url:

Javascriptwriter: You can convert any string to a URL-encoded string (suitable for transmission as a query string or, generally speaking, as part of a URL) using the JavaScript functions escape,encodeURI and encodeURIComponent.

From an ASP dot net blog  : Understand that in, virtual path in the URL with colon (:) is not allowed. To solve this problem, i replace the colon (:) with ASCII value for colon : (please check

If you are working with javascript,  it provides a number of functions that encode and decode special characters

MSDN JScript Reference – escape()encodeURI()encodeURIComponent()

Mozilla Developer Core Javascript Guide – escape()encodeURI()encodeURIComponent()

ASCII Table –

W3C’s URIs, URLs, and URNs: Clarifications and Recommendations 1.0 –

Iframe JQuery, if you are using jQuery 1.6 and up, you want to use .prop() rather than .attr():

One thing to consider:

//import org.apache.commons.lang.StringEscapeUtils;
StringEscapeUtils.escapeJavaScript(out, str)

Documented at :



February 16, 2013 Posted by | Uncategorized | Leave a comment