Java decoding of javascript encodeURIComponent?

A

AlextLittle

Hi,
I'm attempting to retrieve (in my servlet) the values from a url
parameter which have been encoded with javascript encodeURIComponent,
because they contain non-latin characters (and/or punctuation) but I
can't seem to get it to work correctly - i.e. it's not converting the
characters back correctly.

In my serlvet I've set: request.setCharacterEncoding("UTF-8"); then I
try to use:

String groups = params.getParameter("groups");
String decodedParam = URLDecoder.decode(groups,"UTF-8");

But if I then try to compare decodedParam against the original strings
(used to previously generate the webpage), I can't get them to match
if any non-latin chars are in the decodedParam. - the following
results in 'found' messages when decodedParam is purely latin chars
and 'not found' messages non-latin chars included:

if(originalGroupName.equals(decodedParam)){
System.out.println("found:"+originalGroupName);
} else {
System.out.println("not found:"+originalGroupName);
}


Any ideas where I might be going wrong as it's driving me a little
mad!!
All help much appreciated ;-)
Alex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top