Liou Wang wrote:
>
> Hey, all,
>
> I am working on a web based database management application. Well, the
> designing needs to input Chinese characters into the database via the HTML
> form. As the specification says that the "get" method only supports
> ISO8859-1 and "post" method supports much more, I choose the "post" method.
> But no matter how I specify the character set the form should use, the
> servlet always gets the input in the ISO8859-1 style. Moreover, like in the
> "get", the one Chinese character is splitted into 2 chars whose high bytes
> set to 0xFF. So bad! Can any one help me on that case, like how to correctly
> set the character set the form should use, or, how to set the servlet
> properties?
Your HTML page should specify the charset in a meta tag in the header: <meta
http-equiv="Content-Type" content="text/html; charset=utf-8">. Replace utf-8
with the appropriate charset designation for Chinese characters.
Then in your servlet get the parameter:
stringToConvert = getParameter("name");
On the project I work, we created a utility function to do the conversion. We
pass the string obtained by getParameter, and a string that specifies the
character set used by the web page:
byte[] Bytes = stringToConvert.getBytes("8859_1");
tempStringUnicode = new String(Bytes, stringsCharSet);
K Mukhar
___________________________________________________________________________
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