Hi Tomasek,
Tomasek> E. g. I am reading XML file in my JSP page and printing its
Tomasek> contents to the page. Although the XML is in UTF-8, the page
Tomasek> contains wrong characters.
Tomasek> Similar output problems are with JDBC fetched data. I read some textual
Tomasek> cntent from MySQL database, but printing them to the JSP causes the same
Tomasek> problem, as with XML: national characters are substituted with question
Tomasek> marks (?) or squares.
Question marks (\uFFFD) means jvm can't encode characters.
This sometimes occur when fetching String/char from IO.
JVM sometimes recognize String/char as iso-8859-01 read from
InputStream, so you should re-encode it to other charset.
e.g.)
Suppose fetched String is "original", then
String encoded = new String(original.getBytes("iso-8859-01"),"UTF-8");
OR, wrap InputStream by InputStreamReader(in,"UTF-8")
If you can use JDK1.4, then you can use better solution using nio.
In the message "Character encoding in JSP/Servlet"
<009c01c216cc$98857de0$[EMAIL PROTECTED]>
Petr Tomasek <[EMAIL PROTECTED]> wrote:
Tomasek> Hi,
Tomasek> I have a big trouble with using different encoding than US-ASCII in my JSP.
Tomasek> What encoding should I use, if I want to make pages for european users? I
Tomasek> think the best is to use UTF-8, since it includes all character sets. I
Tomasek> tried to do this:
Tomasek> <%@page contentType="text/html; charset=UTF-8" %>
Tomasek> I am developing my JSP in NetBeans, so I set the source text encoding also
Tomasek> to UTF-8. In compiler options, I set the compiler encoding also to UTF-8.
Tomasek> I have no trouble with viewing the JSP page in the browser, the sorce text
Tomasek> is ok. But some of the dynamicaly generated output is wrong. E. g. I am
Tomasek> reading XML file in my JSP page and printing its contents to the page.
Tomasek> Although the XML is in UTF-8, the page contains wrong characters.
Tomasek> Similar output problems are with JDBC fetched data. I read some textual
Tomasek> cntent from MySQL database, but printing them to the JSP causes the same
Tomasek> problem, as with XML: national characters are substituted with question
Tomasek> marks (?) or squares.
Tomasek> I am using NetBeans 3.2 as IDE, Tomcat 3.2 as JSP server and Windows 2000
Tomasek> SP-2 as OS.
Tomasek> Did you encounter any problem like this? Thanks for any help.
Tomasek> Petr Tomasek, Prague, Czech Republic
Tomasek> ___________________________________________________________________________
Tomasek> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
Tomasek> of the message "signoff SERVLET-INTEREST".
Tomasek> Archives: http://archives.java.sun.com/archives/servlet-interest.html
Tomasek> Resources: http://java.sun.com/products/servlet/external-resources.html
Tomasek> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html