Sidebar

How do I unescape %40 from a queryString?

0 votes
381 views
asked Aug 21, 2013 by mike-r-7535 (13,830 points)
edited Nov 30, 2016 by michael-h-5027
I have a channel that is an HTTP Listener, and it receives a queryString.  This queryString has an email address, but the @ symbol shows up as %40.  I have tried using qie.unescapeHtml(), but that didn't change anything.  I know the %40 should be @. I think that I want to url decode the %40 to @.

1 Answer

+1 vote
 
Best answer

%40 is a URL encoded @ character.  Java has some helper classes to do this encode and decode URL characters.

To URL encode, use the following:

var originalQueryString = "email=support@qvera.com";

var encodedQueryString = java.net.URLEncoder.encode(originalQueryString, "UTF-8");

The above results in "email=support%40qvera.com"

 

To URL decode use the following:

var encodedQueryString = "email=support%40qvera.com";

var decodedQueryString = java.net.URLDecoder.decode(encodedQueryString, "UTF-8");

The above results in "email=support@qvera.com"

Here is a reference for other URL encoding characters.

answered Aug 21, 2013 by mike-r-7535 (13,830 points)
edited Nov 30, 2016 by michael-h-5027
...