You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by SongDongsheng <eg...@sohu.com> on 2001/09/11 04:00:01 UTC

How can set/get platform's default charset ?

Hi,

The file 'jakarta-tomcat-4.0-cvs/catalina/src/share/org/apache/catalina/util/RequestUtil.java' using platform's default charset frequently, How can I set/get it ?

Thanks advance,

Dongsheng, Song


Re: How can set/get platform's default charset ?

Posted by kanpi <ka...@ekuma.net>.
 import  sun.io.*;
  public class EncodingCheck
  {
 public static void main(String args[])
 {

   System.out.println("System default encoding = "
     + System.getProperty("file.encoding"));

          System.out.println("ByteToCharConverter= "
            + ByteToCharConverter.getDefault());
          System.out.println("CharToByteConverter= "
            + CharToByteConverter.getDefault());

          int i = "XXXXX".length();
          System.out.println("System String.length = "
            + i);
  }
  }

System.setProperty() is defined also, but I have never used it.  When coding i18n
(internationalization, 18 chars between first i and last n), be careful about
javac -encoding <encoding> foo.java

As an example, when compiling the above, where XXXXX is your country's multi-byte
character, and the char is hard-coded, javac -encoding is required.

Welcome to the complicated i18n world.

akira kumakiri