About Chinese issues

zhaozj2021-02-08  213

Many friends have made opinions and suggestions for the Chinese display of virtual Xiaolong Pavilion. I would like to express my gratitude.

In JSP, Chinese garbled often makes people tempted.

For a common countermeasure for Chinese processing, it is often two types below online:

<% @ Page ContentType = "text / html; charset = GB2312"%>

or:

<%

String hi = "Hello";

Byte [] TMPBYTE = Hi.GetBytes ("ISO8859_1");

Hi = new string (tmpbyte);

Out.print (hi);

%>

Virtual Xiaolong Pavilion also modified the above two methods, which turned from version 1.1.

By simple summary, the Chinese processing in the example occurs in the following places:

1 In the URL, the Chinese parameters are included, you can read it directly.

E.g:

<% = Request.getParameter ("ShowWord")%>

2 Various SQL operations related to the database

The Access used here has no problem.

3 Read the Chinese value submitted in the HTML Form form

Encoding in JSWDK, more simple, such as:

String name1 = new string (Request.getParameter ("user_id"). GetBytes ("ISO8859_1");

In addition, in the support of JDK1.3, no need to join

<% @ Page ContentType = "text / html; charset = GB2312"%>

In JDK1.2.2, even if the two methods are used simultaneously.

And in the RESIN platform, the situation is better. Just join the first line of the page:

<% @ Page ContentType = "text / html; charset = GB2312"%> can process Chinese correctly.

If adding codes, it is not correct.

"Chinese included in the session

In JSWDK, it is strange that if the value read from the Form is encoded, it can be displayed correctly; but it will not be directly given the Chinese value.

The RESIN platform is very good, the same.

6 Display Chinese correctly after the variable value is verified.

For example, the following procedures:

<% @ Page ContentType = "text / html; charset = GB2312"%>

<%

String hi = "Hello";

Byte [] TMPBYTE = Hi.GetBytes ("ISO8859_1");

Hi = new string (tmpbyte);

Out.print (hi);

%>

Also JSWDK1.0.1, the above representation is not problematic in JDK1.2.2, but it cannot be displayed in JDK1.3.

The RESIN platform is very good, the same, after the test, only need to make up in

No need to display Chinese correctly without <% @ page contenttype = "text / html; charSet = GB2312"%> Experience:

JSWDK may only be used for normal development, stability, and other issues that may not be as commercial software.

Since the JDK1.3 performance is better than JDK1.2.2, and the support of Chinese is also good, it should be used.

As a free commercial software, RESIN is not only fast, stable, automatically compiled, but can indicate the wrong line, but can support the use of JavaScript on the server side, and at least I feel good for Chinese support.

Of course, if you don't have to do anything, you can correctly display the Chinese will be what we are looking forward to.

In addition, it is believed that there should be no such problem under UNIX / Linux / Solaris.

转载请注明原文地址:https://www.9cbs.com/read-2294.html

New Post(0)