tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexandre Roger <aroger-tomc...@marquedor.com>
Subject I18N problems with JVM 1.3.1
Date Thu, 20 Nov 2003 21:49:52 GMT
I have a problem with accents that is occurring when I run Tomcat 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:

The following JSP:
<html>
Convert a byte: <%=  new String(new byte[]{(byte)'é'}) %><br>
Convert ISO: <%= new String(new byte[]{(byte)'é'}, "ISO8859_1") %><br>
Encoding: <%= sun.io.ByteToCharConverter.getDefault() %><br>
Locale: <%=java.util.Locale.getDefault()%>
</html>

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 sun.io.ByteToCharConverter.getDefault() - 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 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...

Anyone has any suggestion?

Alex


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message