Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4375816

java ignores -Dfile.encoding parameter

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P2 P2
    • None
    • 1.3.0
    • core-libs
    • sparc
    • solaris_2.6



      Name: dfR10049 Date: 10/03/2000



      Java ignores -Dfile.encoding while creating Reader/Writer with default
      encoding. It always uses system default on Solaris 2.7.

      On Solaris 2.6 if LC_CTYPE=ru it also ignores -Dfile.encoding parameter.

      jdk1.1.* works correctly.

      This is the test demonstrated the bug:

      -------------------------------------
      import java.io.*;

      public class Test {

        static public void main (String[] args) {
              System.out.println("file.encoding " +
                      System.getProperty("file.encoding"));
              OutputStreamWriter wtr =
                      new OutputStreamWriter(new ByteArrayOutputStream());
           System.out.println("encoding " + wtr.getEncoding());
        }
      }

      -------- output from the text on Solaris 2.7 ----------------
      (jdk versions: 1.4)

      #> uname -a
      SunOS falcon 5.7 Generic_106541-12 sun4u sparc SUNW,Ultra-5_10
      #> java -version
      java version "1.4.0beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0beta-b34)
      Java HotSpot(TM) Core VM (build 1.3-internal, interpreted mode)

      #> export LC_CTYPE=C

      #> java Test
      file.encoding 646
      encoding ASCII

      #> java -Dfile.encoding=Cp037 Test
      file.encoding Cp037
      encoding ASCII

      #> export LC_CTYPE=ru

      #> java Test
      file.encoding ISO8859-5
      encoding ISO8859_5

      #> java -Dfile.encoding=Cp037 Test
      file.encoding Cp037
      encoding ISO8859_5

      example of correctly behavior on Solaris 2.7:

      #> /usr/local/java/jdk1.1.8/solaris/bin/java -Dfile.encoding=Cp037 Test
      K@Ãðó÷%@Ãðó÷%


      -------- output from the text on Solaris 2.6 ----------------
      #> uname -a
      SunOS helmet 5.6 Generic_105181-16 sun4u sparc SUNW,Ultra-

      #> java -version
      java version "1.4.0beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0beta-b34)
      Java HotSpot(TM) Core VM (build 1.3-internal, interpreted mode)

      correctly works when LC_CTYPE=C

      #> export LC_CTYPE=C
      #> java Test
      file.encoding 8859_1
      encoding ISO8859_1

      #> java -Dfile.encoding=Cp037 Test
      K@Ãðó÷@Ãðó÷

      Incorrectly works when LC_CTYPE=ru
      #> export LC_CTYPE=ru

      #> java Test
      file.encoding koi8-r
      encoding KOI8_R

      #> java -Dfile.encoding=Cp037 Test
      file.encoding Cp037
      encoding KOI8_R


      ----------------------------------------------

      ======================================================================

            mr Mark Reinhold
            fdasunw Fda Fda (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: