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
----------------------------------------------
======================================================================
- duplicates
-
JDK-4163515 -Dfile.encoding option doesn't affect default ByteToChar converter
- Closed