Subject: Re: I18N Problem with Chinese Character
From: "Liu Yan" <[EMAIL PROTECTED]>
 ===
hi,

The problem is completely solved now, I think :-)

The Chinese problem involves:

1) Static Chinese character in a JSP page
2) Chinese characters sent by HTTP Request and Response
3) Chinese characters sent to DBMS back and forth

I found tons of articles on I18N suggest using UTF-8 encoding, so I follow
this.

1) For static Chinese character, add the following line at the beginning of
each JSP page:

  <%@ page contentType="text/html; charset=UTF-8" %>

2) For characters sent through HTTP, you can use some encoding filter to
solve this. You can refer to http://www.anassina.com/struts/i18n/i18n.html
for a tutorial on this. There is a filter you can use in your project. Since
I am using WebLogic 6.1, I also found a convenient setting in web.xml to do
the same job. Add the following lines in your web.xml file:

<web-app>
<context-param>
    <param-name>weblogic.httpd.inputCharset./*</param-name>
    <param-value>UTF8</param-value>
</context-param>
......
</web-app>

and in your weblogic.xml file, add the following:

<weblogic-web-app>
  <description>WebLogic descriptor</description>
  <jsp-descriptor>
    <jsp-param>
      <param-name>encoding</param-name>
      <param-value>UTF8</param-value>
    </jsp-param>
  </jsp-descriptor>
......
</weblogic-web-app>

3) For characters sent to and from DBMS, I use standard String(byte[],
encoding) to convert the characters. It is a bit tedious but it works fine
for SQL Server 2000 of my project. I believe it will work in Oracle too.

Hope it helps.
Good day!

Liu Yan


"Gordon Luk" <[EMAIL PROTECTED]> ?¤J®ø®§·s
?:[EMAIL PROTECTED]
> Hi Liu Yan,
>
> have you meet the input chinese problem? if yes, how to solve it ? could
> you share your experiense? Thanks.
>
> Gordon
>
> Struts Newsgroup (@Basebeans.com) wrote:
>
> >Subject: Re: I18N Problem with Chinese Character
> >From: "Liu Yan" <[EMAIL PROTECTED]>
> > ===
> >hi,
> >
> >Thanks. Yes, it helps. And now the Chinese character is displayed OK.
> >
> >I used the native2ascii command with -encoding UTF-8 parameter and with
no
> >exception. I believe that the your exception is caused by non-UTF-8
format
> >of your original properties file.
> >
> >Good day!
> >Liu Yan
> >
> >"nsg" <[EMAIL PROTECTED]> $B<LF~>CB)?7(B
> >?:[EMAIL PROTECTED]
> >
> >>you should turn your resource file to UTF-8 encoding using native2ascii
> >>command.
> >>that command locates in your-jdk-home\bin directory.
> >>detail command line is listed below:
> >>
> >>native2ascii ApplicationResources_zh.properties
> >>ApplicationResources_zh.propertiesX
> >>
> >>the first parameter is source file,second is destination file. Use the
> >>destination file as your resource file.
> >>
> >>Many articles introduce that the encodeing parameter should be specified
> >>like following:
> >>
> >>native2ascii -encoding UTF-8 ApplicationResources_zh.properties
> >>ApplicationResources_zh.propertiesX
> >>.
> >>but if so, an exception would be thrown.I dont know what reason causes
the
> >>exception?
> >>
> >>of course,you use first command and should be OK.
> >>
> >>
> >>hope helps for you.
> >>
> >>
> >>Laker
> >>
> >>
> >>
> >>
> >>----- Original Message -----
> >>From: "Struts Newsgroup" <@[EMAIL PROTECTED]>
> >>To: <[EMAIL PROTECTED]>
> >>Sent: Friday, March 15, 2002 9:40 PM
> >>Subject: I18N Problem with Chinese Character
> >>
> >>
> >>>Subject: I18N Problem with Chinese Character
> >>>From: "Liu Yan" <[EMAIL PROTECTED]>
> >>> ===
> >>>hi List,
> >>>
> >>>I am using struts-1.0.2 with WebLogic 6.1-sp2. For an I18N project, I
> >>>followed the steps:
> >>>
> >>>1) I created ApplicationResources.properties and
> >>>ApplicationResources_zh.properties files to store strings.
> >>>2) The whole project is using UTF-8 encoding.
> >>>3) On the beginning of each JSP page, add:
> >>>   <%@ page contentType="text/html; charset=UTF-8" %>
> >>>
> >>>For static Chinese character in JSP page, this setting goes well. But
> >>>
> >when
> >
> >>I
> >>
> >>>tried to use:
> >>>
> >>><bean:message key="prompt.username"/>
> >>>
> >>>to get some strings from ApplicationResources_zh.properties file, the
> >>>
> >>output
> >>
> >>>is corrupted.
> >>>
> >>>I am suspecting this is the <bean:message> taglib's problem, but
decided
> >>>
> >>to
> >>
> >>>drop a letter here for a quick answer. Am I doing something wrong or I
> >>>
> >>have
> >>
> >>>to wait for the upcoming 1.1 beta release?
> >>>
> >>>Regards!
> >>>Liu Yan
> >>>
> >>>
> >>>
> >>>
> >>>--
> >>>To unsubscribe, e-mail:
> >>>
> >><mailto:[EMAIL PROTECTED]>
> >>
> >>>For additional commands, e-mail:
> >>>
> >><mailto:[EMAIL PROTECTED]>
> >>
> >>>
> >>
> >>--
> >>To unsubscribe, e-mail:
> >>
> ><mailto:[EMAIL PROTECTED]>
> >
> >>For additional commands, e-mail:
> >>
> ><mailto:[EMAIL PROTECTED]>
> >
> >
> >
> >
> >--
> >To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> >For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
> >
>
>



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to