A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Problem with URLEncoder.encode and request.getparameter with chinese characters
Joined: Feb 19, 2009
Aug 20, 2009 03:33:28
This is the URL that I use to invoke my
As you can see, the parameter has a unicode character 団. So I use
URLEncoder.encode ( "団", "UTF-8" ) ;
and now my URL becomes
However, from the servlet, calling
request.getParameter ( "p1" ) ;
already return some gibberish that cannot be decoded with
. BTW, invoking
URLDecoder.decode ( "%E5%9B%A3", "UTF-8" ) ;
does give me the original unicode character. It`s just that the servlet has garbled the parameter before it can even be decoded. Does anyone know why?
Request.gerparameter doesnt decode parameter with UTF-8?
Joined: Sep 14, 2006
Aug 26, 2009 19:49:41
You need to translate the character set of the parameter
String reqVal = new String(request.getParameter("p1").getBytes("iso-8859-1"),"iso-8859-2");
Its just an example iso code, you need to find the correct one for Chinese.
I agree. Here's the link:
subject: Problem with URLEncoder.encode and request.getparameter with chinese characters
POST data with a file upload
JSP Submit from java code
error while submitting an http web request
I need the URL unicode representation of <> angle brackets?
Few Doubts about encoding
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014