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
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