Chinese - German character woes in JSP

J

Jeff

Having a problem displaying both german and chinese characters from a
UTF-8 database on the same *.jsp page.

Can make Chinese characters appear correctly by including the following
lines:

<%@ page pageEncoding="UTF-8" %>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">


However, if I include the <meta> tag it then makes special german
characters unreadable. If I remove the <meta> tag German characters
display properly but Chinese characters do not.

We are trying to display them on the same page, because ultimately
Chinese and German will be served on the same site.

TIA,
Jeff
 
M

Marco Schmidt

[comp.lang.java removed - group is not active anymore, although some
servers still carry them for whatever reason]

Jeff:

[...]
However, if I include the <meta> tag it then makes special german
characters unreadable. If I remove the <meta> tag German characters
display properly but Chinese characters do not.

Do you encode the German characters correctly as UTF-8? Something like
that:

String test = "ae=ä oe=ö ue=ü Ä=Ae Ö=Oe Ü=Ue ß=ss";
byte[] rawOutputData = test.getBytes("UTF-8");

Hopefully this posting gets to you with all special characters encoded
correctly.

Regards,
Marco
 
L

Lothar Kimmeringer

However, if I include the <meta> tag it then makes special german
characters unreadable. If I remove the <meta> tag German characters
display properly but Chinese characters do not.

Seems that the latin1-characters are not UTF-8 encoded
but only the chinese ones. Hard to say whether this happens
in the JSP-engine or it's your fault, but you can try to
explicitly convert your dynamic output to UTF-8 for yourself
with the code Marco already posted.


Regards, Lothar
--
Lothar Kimmeringer E-Mail: (e-mail address removed)
PGP-encrypted mails preferred (Key-ID: 0x8BC3CD81)

Always remember: The answer is forty-two, there can only be wrong
questions!
 
C

chris

Jeff said:
Having a problem displaying both german and chinese characters from a
UTF-8 database on the same *.jsp page.

Can make Chinese characters appear correctly by including the following
lines:

<%@ page pageEncoding="UTF-8" %>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">


However, if I include the <meta> tag it then makes special german
characters unreadable. If I remove the <meta> tag German characters
display properly but Chinese characters do not.

We are trying to display them on the same page, because ultimately
Chinese and German will be served on the same site.

TIA,
Jeff

How are your German texts being generated? If they are coming from Java
strings and UTF-8 encoding is specified, then everythig should work. If
however you're fetching 8-bit German text out of a file or a database then
somewhere along the line you need to translate from ISO 8859-1 to UTF-8.
Check that your default encoding is set to UTF-8 and that all your
conversions between byte[] and String are kosher.

If you consistently use UTF-8 and the web browser is not totally broken
(big "if"!) then it should be perfectly possibly to mike German and Chinese.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top