tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexandre Roger <>
Subject I18N problems with JVM 1.3.1
Date Fri, 21 Nov 2003 21:19:09 GMT
Good day to all posters and lurkers, 

I have a problem with accents that is occurring when I run Tomcat 4.1
under JVM 1.3.1, but not under 1.4.

I am trying to convert a byte[] (that comes from a socket in the
production code) to a String. The bytes come from a CGI and are
ISO8859-1. When I do String(myByteArray), I get a question mark
character where I should get an accented character. Following some
advice picked up from the web, I have forced the JVM to start with a
file.encoding=ISO8859_1. This works perfectly when running Blackdown 1.4
but fails when using Blackdown 1.3.1. Here is a demo JSP:

Convert a byte: <%=  new String(new byte[]{(byte)'é'}) %><br>
Convert ISO: <%= new String(new byte[]{(byte)'é'}, "ISO8859_1") %><br>
<!--the byte is a 'e acute', any accented character produces the bug-->
Encoding: <%= %><br>
Locale: <%=java.util.Locale.getDefault()%>

Here is the CATALINA_OPTS used:
-Dfile.encoding=ISO8859_1 -Duser.language=fr -Duser.region=CA"

If I do a Sytem.getProperty("file.encoding"), I get ISO8859_1 in both
JVM, but - which is what
String(byte[]) uses - says ASCII for JVM 1.3 and ISO8859_1 for JVM 1.4.

It would also seem this is not the only setting getting ignored by the
1.3 JVM... The language and region settings result in a locale of fr_CA
for 1.4 but are ignored (and default to en_US) for 1.3

I know I could simply force the encoding as I did in line 2 of the JSP,
but I am trying to migrate a whole lot of code from Websphere to Tomcat
that was written by many developers and would rather not seek out all
instances of byte arrays being converted to strings. Moreover, I suspect
this is merely the tip of the iceberg and other occurrences of accents
being garbled might be going on in less obvious places. 

I also could just use version 1.4 of the JVM, but the only widely
available .deb for JVM 1.4 is a BETA. If at all possible, I'd like to
use a production release managed by the debian package manager and
picked up from official Blackdown mirrors...

Could anyone offer a suggestion?


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message