On 01/09/2011 03:41, David Wall wrote:
> I'm trying to track down a character encoding issue that I've been
> having, but don't really understand. Hopefully one of you will know what
> the answer is.

I suspect you need:
<%@ page pageEncoding="UTF-8" %>
at the start of your JSP.

.java files are written using UTF-8 by default so if what you see there
is wrong then the original .jsp file was read with the wrong encoding.

Tomcat determines the encoding based on a number of factors. For the
details see line 326 onwards of
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/ParserController.java?view=annotate

The short version is if it is XML, it uses the encoding defined in the
XML doc, if it isn't XML it uses the value of pageEncoding. The
fall-back is ISO-8859-1.

> <%@ page contentType="text/html; charset=utf-8" session="true"
> isELIgnored="true" %>

You'll still need this to tell the browser to use UTF-8 to display the data.

> So I figured it was the default character encoding of the JVM causing me
> some grief. I checked and the default on my Windows PC is Cp1252. But
> when I change this with the JVM argument -Dfile.encoding=UTF8, I am no
> better off.

That is expected. file.encoding is not always read/write and should
never be relied upon to fix any encoding problems.

HTH,

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to