Dear Leos,
Thank you for you help.
Your code is working with UTF-8 user input in an form embeded in
an UTF-8 charset page. My situation is the page is set as UTF-8, but
usr's input may be Shift-JIS. I am using IE and I got corrupted parameter
String by calling getParameter() and change it's coding afterwards.
I'm thinking:
1) how can I get the raw form input in servlets? But if the browser send
it in wrong way, then forget about it. In W3C's recommendation, there is
a new attribute "ACCEPT-CHARSET" in the "form" tag which I guess
should allow user designate specific charset used for sending user's typein.
But neither Netscape nor IE support this attribute right now.
2) Use JavaScript or whatever to change the current page's charset before
submit the form. Anybody try this?
Thanks for any help,
Ning
Leos Urban wrote:
> > I got a problem. I'm building a site supporting multi langages.
> > So I chose UTF8 for encoding, That is, the page's content
> > type is set for UTF8. But user may type in native code such
> > as SJIS when they submit search key words. when I get the
>
> Test this example:
>
> public String getUtfPar(String strWebForm) throws IOException
> {
> if (strWebForm!=null)
> return new String (strWebForm.getBytes("iso8859-1"),"utf-8");
> else
> return null;
> }
>
> response.setContextType("text/html;charset=utf-8");
> String myInputText = getUtfPar(request.getParameter("someFormText"));
> ...
>
> Leos
>
> ___________________________________________________________________________
> 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
___________________________________________________________________________
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