Hi,

Try saving your resource file with Chinese text as GB2312 encoded text.
There is a tool in the $JAVA_HOME/bin dir called 'native2ascii'.  Run this
against your file and you will have a pure ascii file with \uXXXX (X = hex
number) to represent the double byte chinese chars.  in the javadoc it
specifies that java.util.Properties should be able to decode a stream of
this data and convert it into 16bit unicode.  If struts uses this, then your
java strings should be OK.

To verify that you have read in the resource correctly, I suggest writing a
small java app that can write the data to screen because the character
encoded will be preserved in Java.

Your next problem is going to be writing data using the jspWriter.  I would
expect the jsp writer to also use ISO-8859-1 encoding when converting
unicode java strings to a byte stream, this would completely mess up your
chinese chars.  You would need to change the encoding in the jspWriter to be
GB2312 if this is to work correctly.  What Jeff says is also correct, you
would need to specify the encoding used in the http headers.

If neither of the two suggestions above work, then your other option is to
sub-class the relevant code and override the methods that do the encoding
with your own.  But then you are probably entering a whole world of pain :)

Sorry, I cant be of more help, I have only ever done double byte i18n work
on normal apps and not web apps.

Regards,
Chris.

-----Original Message-----
From: Julia Yang [mailto:[EMAIL PROTECTED]]
Sent: 12 December 2001 21:12
To: Struts Users Mailing List
Subject: RE: Help, How to display Chinese in jsp by using message tag ?


I did, also put double quotes around the Chinese character but it gave
me the following jsp exception for some reason

weblogic.utils.ParsingException: nested TokenStreamException:
antlr.TokenStreamI
OException
        at weblogic.servlet.jsp.JspLexer.parse(JspLexer.java:900)
        at weblogic.servlet.jsp.JspParser.doit(JspParser.java:71)
        at weblogic.servlet.jsp.JspParser.parse(JspParser.java:175)
        at weblogic.servlet.jsp.Jsp2Java.outputs(Jsp2Java.java:113)
        at
weblogic.utils.compiler.CodeGenerator.generate(CodeGenerator.java:253
)
        at weblogic.servlet.jsp.JspStub.compilePage(JspStub.java:313)
        at weblogic.servlet.jsp.JspStub.prepareServlet(JspStub.java:180)
        at weblogic.servlet.jsp.JspStub.prepareServlet(JspStub.java:148)
        at
weblogic.servlet.internal.ServletStubImpl.getServlet(ServletStubImpl.
java:306)
        at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:208)
        at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:246)
        at
weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppSe
rvletContext.java:1265)
        at
weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestIm
pl.java:1631)
        at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
        at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
>
-----Original Message-----
From: Jeff Martin [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, December 12, 2001 12:22 PM
To: Struts Users Mailing List
Subject: RE: Help, How to display Chinese in jsp by using message tag ?

Have you tried putting the contentType in the JSP page directive like I
had previously suggested? The html spec at http://www.w3.org/TR/html4/
section 5.2.2 says:

   To sum up, conforming user agents must observe the following
   priorities when determining a document's character encoding (from
   highest priority to lowest):
    1. An HTTP "charset" parameter in a "Content-Type" field.
    2. A META declaration with "http-equiv" set to "Content-Type" and a
       value set for "charset".
    3. The charset attribute set on an element that designates an
       external resource.

Therefore, if your web server is sending the content type as part of the
HTTP header, your meta tag will be ignored.

Jeff

-----Original Message-----
From: Julia Yang [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, December 12, 2001 2:05 PM
To: Struts Users Mailing List
Subject: RE: Help, How to display chinese in jsp by using message tag ?


Thanks for you reply. You gave a good point. But I still don't know how
to make it work. Can you or any body tell me how to fix it if you
happened to know.
What I did was: edit the application_zh.properties in note pad and save
in UTF-8 encoding.
In my jsp I tried each of the following
        <head><meta http-equiv="Content-Type" content="text/html;
charset=UTF-8"></head>
        <head><meta http-equiv="Content-Type" content="text/html;
charset=gb2312"></head>

same problem: nothing shows

if I put English text instead of Chinese character in the property file,
it works fine. Does it explain some thing ?

Thanks

Julia


-----Original Message-----
From: Chris Birch [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, December 12, 2001 10:04 AM
To: Struts Users Mailing List
Subject: RE: Help, How to display chinese in jsp by using message tag ?

Hi,

My guess is that the code being used to load the file off disk is
decoding
the text using the wrong charset to decode.  In the UK, the JVM's
default
charset is normally iso-8859-1 and this is used when loading any text
files
from disk and converting them into double byte unicode (Java Strings).

In the javadoc for java.util.Properties, the following is found:

"When saving properties to a stream or loading them from a stream, the
ISO
8859-1 character encoding is used. For characters that cannot be
directly
represented in this encoding, Unicode escapes are used;"

I assume this applies applies to the struts resource implementation, it
will
certainly apply to java.util.PropertyResourceBundle.

According to the docs, after running the jsdk tool 'native2ascii' to
convert
your GB2312 text into unicode escaped ascii, things may work.  The docs
seem
to indicate that property loading streams will convert the unicode
escapes.

Hope this helps, regards,
Chris.

-----Original Message-----
From: Julia Yang [mailto:[EMAIL PROTECTED]]
Sent: 12 December 2001 01:11
To: [EMAIL PROTECTED]
Subject: Help, How to display chinese in jsp by using message tag ?


Hi, all
Can any one tell me how to use message tag to display Chinese in jsp

I have a property file called application_zh.properties which has
English at left and Chinese at right for each entry.
Example: expression_input.ok= ¹«Ê½

In my jsp I use message tag to find the matched Chinese through English
text and try display the  it .
Example: <bean:message key="expression_input.ok"/>

In my jsp, I set up the
<head><META http-equiv="Content-Type" content="text/html;
charset=gb2312"></head>

My problem is the application found the file but display nothing.

Thanks

Julia

--
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]>


--
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