-
Bug
-
Resolution: Fixed
-
P2
-
1.4.0
-
beta3
-
x86
-
windows_nt
ingrid.yao@Eng 2001-08-10
J2SE Version (please include all output from java -version flag):
java version "1.4.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b65)
Java HotSpot(TM) Client VM (build 1.4.0-beta-b65, mixed mode)
Does this problem occur on J2SE 1.3? Yes / No (pick one)
No
Operating System Configuration Information (be specific):
WinNT Sp5 with Slovenian regional setting
Hardware Configuration Information (be specific):
PIII / 256MB RAM
Bug Description:
Encodings behave differently between 1.3.1 and 1.4.
Steps to Reproduce (be specific):
This attached java app throw exception immediately with JDK 1.3.
With JDK1.4, if you set the regional settings (in control
Panel/Regional Settings) to English(United States) it behaves OK,
but if you set it to Slovenian, it will first displays 'A'(should
never been printed), and then a stack trace. Some encodings behave
differently depending how you use them and there are two in this source code:
test program - Untitled1.java
------------------------------
import java.io.*;
public class Untitled1 {
public static void main(String[] args) {
try {
byte[] test = { 65 };
/* String charset = "privzeto(samodejno)"; */
String charset = "windows/1250";
System.out.println(new String(test, charset));
new InputStreamReader(new ByteArrayInputStream(test), charset);
} catch (Exception e) {
e.printStackTrace();
}
}
}
test result
---------------
H:\CAP\bug\novi>java -version
java version "1.4.0-beta_refresh"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta_refresh-b72)
Java HotSpot(TM) Client VM (build 1.4.0-beta_refresh-b72, mixed mode)
H:\CAP\bug\novi>java test.Untitled1
A <------------- not right
java.io.UnsupportedEncodingException: windows/1250
at sun.io.Converters.getConverterClass(Converters.java:117)
at sun.io.Converters.newConverter(Converters.java:148)
at sun.io.ByteToCharConverter.getConverter(ByteToCharConverter.java:67)
at java.lang.StringCoding.decode(StringCoding.java:186)
at java.lang.String.<init>(String.java:325)
at java.lang.String.<init>(String.java:346)
at test.Untitled1.main(Untitled1.java:16)
H:\CAP\bug\novi>b:\jdk1.3.1\win\bin\java -version
java version "1.3.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)
H:\CAP\bug\novi>b:\jdk1.3.1\win\bin\java test.Untitled1
java.io.UnsupportedEncodingException: windows/1250
at sun.io.Converters.getConverterClass(Converters.java:107)
at sun.io.Converters.newConverter(Converters.java:138)
at sun.io.ByteToCharConverter.getConverter(ByteToCharConverter.java:67)
at java.lang.String.getBTCConverter(String.java:124)
at java.lang.String.<init>(String.java:411)
at java.lang.String.<init>(String.java:432)
at test.Untitled1.main(Untitled1.java:16)
========================================================================
Narrowed this down to occurring as follows. If the default encoding for
the system locale is one of the 1.4 nio implemented set, ie:
ISO-8859-1, US-ASCII, Windows-1252, UTF-8, ISO-8859-15, UTF-16 (in
various flavors) then the encoding specified within the String
constructor parameter will take effect. However, if the default
encoding for the system locale falls into the other bucket
(i.e Eastern European, East Asian, CJKV locales) then the
encoding used in String encoding and decoding will be the
default encoding and *not* the one explicitly requested. The
previously suggested fix still applies. This information is
provided here just to offer a fuller description of the bug.
###@###.### 2001-08-14