js| Skills | chinese | Chinese garbled
In JSP, Chinese garbled often makes people utterly confused.
For the common countermeasures of Chinese processing, the following 2 kinds are often visible on the Internet:
<%@ page
Contenttype= "text/html;charset=gb2312"%>
Or:
<%
String hi= "Hello";
Byte[]
Tmpbyte=hi.getbytes ("Iso8859_1");
Hi=new
String (Tmpbyte);
Out.print (Hi);
%>
By simply summarizing, the Chinese processing in the example occurs in several places:
1 in the URL with Chinese parameters, you can read directly.
For example:
<%= request.getparameter ("Showword")%>
2 Various SQL operations related to the database
There is no problem with access in this place.
3 Reading HTML
Form Table consignments the Chinese value submitted
In the JSWDK need to be coded, more concise wording such as:
String name1=new
String (Request.getparameter ("user_id"). GetBytes ("Iso8859_1"));
In addition, with the support of jdk1.3, there is no need to join
<%@
Page contenttype= "text/html;charset=gb2312"
%>
Under jdk1.2.2, even 2 methods are not stable at the same time.
But in the resin platform, the situation is better. Just add in the first line of the page:
<%@
Page contenttype= "text/html;charset=gb2312"
%>
can handle Chinese correctly.
If you add code then it is wrong.
5 The Chinese language included in the session
In JSWDK, it is strange that if the value read from form is encoded, it can be displayed correctly;
But it is not possible to give Chinese values directly.
Resin platform is very good, ditto.
6 correctly displays Chinese after assigning Chinese values to variables.
For example, the following programs:
<%@ page contenttype= "text/html;charset=gb2312"
%>
<%
String
hi= "Hello";
Byte[] Tmpbyte=hi.getbytes ("iso8859_1");
Hi=new
String (Tmpbyte);
Out.print (Hi);
%>
</body>
The same is jswdk1.0.1, the above method of representation in the jdk1.2.2 no problem, but under the jdk1.3 can not be displayed.
Resin platform is very good, ditto, after testing, only need to fill in the
<meta
http-equiv= "Content-type" content= "text/html;
charset=gb2312 ">
And not need
<%@ page
Contenttype= "text/html;charset=gb2312"%> can also display Chinese correctly.
Experience:
JSWDK may only be used for general development, and stability and other problems may not be as good as commercial software.
Because the jdk1.3 version performance is better than jdk1.2.2 many times, and the Chinese support is also good, so should be adopted.
As a free commercial software, resin not only fast, stable, automatic compilation, can point to error line, can support the use of JavaScript on the server side, and, at least, I think the support for Chinese is very good.
Of course, if you do not have to do any processing to correctly display the Chinese will be what we expect.
In addition, I believe that under the unix/linux/solaris should not have such a problem.