pradeep wrote:
>
> Hi All
>
> I am working in Jap Environment. And faced a strange situation.
>
> I set Browser charset to "Auto detect-Japanese"
> 2.in the Servlet generated HTML, setting character set to Shift_JIS
>
> So I am should get the URL parameters in Shift_JIS encoded format.
> they are getting passed in ISO-8859-1 encoded format??
>
> What could be reason.I am using
The reason is that browsers don't specify charset for HTTP
requests. If you use GET method, there is no way for specifying
charset. If you use POST method, browsers set just
"application/x-www-form-urlencoded" content-type without
"charset" parameter.
So a servlet has no way how to detect encoding of incoming
request.
There is a workaround:
String foo =
new String(req.getParameter("foo").getBytes("ISO-8859-1"),"Shift_JIS");
Martin
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
INET, a.s. Mgr. Martin Kuba
Kralovopolska 139 e-mail: [EMAIL PROTECTED]
601 12 Brno WWW: http://www.inet.cz/~makub/
Czech Republic tel: +420-5-41242414/33
--------------------------------------------------------------------
PGP fingerprint = D8 57 47 E5 36 D2 C1 A1 C3 48 B2 59 00 58 42 27
http://wwwkeys.cz.pgp.net:11371/pks/lookup?op=index&search=makub
--------------------------------------------------------------------
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html