Globalize your On Demand Business

来源:互联网 发布:linux chown 子目录 编辑:程序博客网 时间:2024/05/01 22:47

Globalize your On Demand Business

  Supporting GB18030 In Web Applications : Retrieve and Display data

We use a JSP file GB18030.jsp to retrieve the GB18030 data in DB2 database via JDBC. In GB18030.jsp, we do not call the methods such as response.setLocale() and response.setContentType(). And then the parameter “charset” in GB18030.jsp determines the value of response.getCharacterEncoding().

We assume the GB18030 data in two kinds of format. One is in Unicode format (UTF-8 or UCS-2). The other is in HTML character references format such as &#xxxxx.

 

Retrieve and Display GB18030 data in Unicode format
There are two results when retrieving GB18030 data:


Figure 6 When the data is retrieved correctly.



Figure 7 When the data is retrieved NOT correctly.

And here is the summary table according to the different charset parameters in GB18030.jsp:

charset parameter in GB18030.jsp

Result

charset=GB18030

Success (Figure 6)

charset=GB2312

Fail (Figure 7)

charset=ISO-8859-1

Fail (Figure 7)

charset=UTF-8

Success (Figure 6)

Retrieve and Display GB18030 data in character references format
Because the HTML character references format such as &#13313 is an encoding-independent character, every View > Encoding can parse the data correctly:

Charset parameter in GB18030.jsp

Result

Charset=GB18030

Success (Figure 6)

Charset=GB2312

Success (Figure 6)

Charset=ISO-8859-1

Success (Figure 6)

Charset=UTF-8

Success (Figure 6)

IE and Netscape’s behavior of displaying GB18030 data in kinds of objects
In GB18030.jsp file, we define HTML objects of Text Area, Text Field, List Box and Drop Down Menu. We retrieve the GB18030 data into these objects. However, we find that IE 6.0 has the weakness to display GB18030 data in some objects, while Netscape 7.0 behaves well.
The weakness of IE 6.0 is that it displays GB18030 data in square in some objects as following though the IE’s font is already set to GB18030 font. The symptom is the same for the IE on Windows XP.

Here is a summary table about this behavior:

HTML objects

IE 6.0

Netscape 7.0

Text Area

OK

OK

OK

Display as Square

OK

List Box

Display as Square

OK

Drop Down Menu

Display as Square

OK

 

 

 

 

 

 

 

 

 

 

Amendment:Explicitly set the font “SimSun-18030” to be used by the objects: in the HTML file, add “ STYLE="font-family:'SimSun-18030' ” as each object’s attribute, and then, GB18030 data display correctly.

IE and Netscape’s behavior of displaying surrogate data
With GB18030.jsp file, we can see that the surrogate data can display correctly in the above four objects both in Netscape 7.0 and IE 6.0, for example,

 
原创粉丝点击