tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Sandiford <Martin.Sandif...@aus.viptone.com>
Subject Re: changing the default character encoding
Date Tue, 26 Feb 2002 01:02:17 GMT
Hi Richard,

If you specifically want the log/other files to be in ISO-8859-1
encoding, might it not be a good idea to create your OutputStreamWriters
(or whatever) with the encoding that you want, rather than rely on the
JDK doing the right thing via defaults?

I am not sure what is going on with your JDBC driver/database encoding.
I think this might be a separate problem from the file encoding issue.
Which database and JDBC drivers are you using?

Martin

"Richard Sand" <rsand@vgalleries.com> writes:
> Hi Andrew, Tomcat list-
>
> I tried setting file.encoding directly on the command-line for launching
> tomcat by doing
>
> export CATALINA_OPTS=-Dfile.encoding=iso-8859-1
>
> before I launched the catalina.sh script.  The catalina.sh script does:
>
>     $JAVA_HOME/bin/java $CATALINA_OPTS -classpath $CP \
>      -Dcatalina.base=$CATALINA_BASE \
>      -Dcatalina.home=$CATALINA_HOME \
>      org.apache.catalina.startup.Bootstrap "$@" start \
>      >> $CATALINA_BASE/logs/catalina.out 2>&1 &
>
> which seems to me properly will put CATALINA_OPTS onto the java command
> line.
>
> Of course, this had no effect, just like every other attempt I've made to
> fix this. :)  Is "file.encoding" exactly the property that needs to be set?
> Will this work?
>
> Thanks!
>
> -Richard
>
> ----- Original Message -----
> From: "Andrew B. Sudell" <asudell@acm.org>
> To: "Richard Sand" <rsand@vgalleries.com>
> Sent: Monday, February 25, 2002 5:48 AM
> Subject: changing the default character encoding
>
>> Richard Sand writes:
>>  > Hi all-  Does anyone know how to specify the default encoding for the
> JVM in
>>  > a linux environment?
>>  >
>>  > I'm having difficulty with my servlets because the JVM on my system
> (sun
>>  > jdk1.3.1 on linux) is defaulting to us-ascii encoding instead of using
>>  > iso-8859-1.  I know I can override the encoding inside my code, but
>>  > according to the package description for java.lang, the JVM determines
> the
>>  > default encoding by looking at the OS.  I tried setting both LANG and
>>  > LC_CTYPE in my shell before launching catalina.sh, but I still couldn't
> get
>>  > the servlets to not default to US-ASCII.
>>  >
>>
>> Haven't tried this on Linux -- let me know it it dosen't work, I can
>> play around with a system at work, that isn't accessible just this
>> moment at home -- but in doing some experimentation on different
>> versions of Solaris and different JDK versions, the startup logic in
>> the JVM went something like
>>
>> - Examine the C local you are running in
>> - Find the character encoding for that locale
>> - map that to a Java encoding as best it can (exact scheme seemed to
>>   vary by JDK release)
>> - set file.encoding system property to that
>>
>> >From there, the Java implementations of String, InputStreamReader, and
>> OutputStreamWriter, base their default on file.encoding.
>>
>> So, try setting the LANG environment variable to someting that dosen't
>> use ASCII. Running 'locale -a' gives a list of choices.  Something
>> like en_US would be a good choice.  I expect you have LANG unset, and
>> are defaulting to either the POSIX or C locales, which are basically
>> the same local and imply ASCII only.  Running 'locale' with no
>> argument will give you an idea what the system is up to.  As you play
>> with setting LANG, you may want to write a short java program to print
>> the default encoding.
>>
>> If I remember when I get to work, I'll mail you a java program to
>> check the encoding, a C program to get the system charset -- assuming
>> it ports to linix quickly -- and a table of example results.
>>
>> Drew
>>
>> --
>>         Drew Sudell     asudell@acm.org      http://www.op.net/~asudell
>>


--
To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>


Mime
View raw message