Name: gm110360 Date: 09/28/2004
FULL PRODUCT VERSION :
java version "1.5.0-rc"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-rc-b63)
Java HotSpot(TM) Client VM (build 1.5.0-rc-b63, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP Professional,
Version 5.1.2600 Service Pack 2 Build 2600
EXTRA RELEVANT SYSTEM CONFIGURATION :
japanese Local Installed, MS932 CODE Page set
A DESCRIPTION OF THE PROBLEM :
Inconsistent behaviour for String.getBytes() ~'windows-31j'
/* convert from UTF-8 encoded HTML-Pages -> internal Java String Format */
public static String convertFromUTF8(String s) {
String out = null;
try {
byte []encodable = s.getBytes();
out = new String(encodable, "windows-31j");
byte []outBA = out.getBytes("windows-31j");
} catch (java.io.UnsupportedEncodingException e) {
return null;
}
return out;
}
REGRESSION. Last worked in version tiger-rc
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
just run the code supplied.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Encoding be properly handled, as was in jdk1.4.2_05
ACTUAL -
Garbage handling of encoding.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Logical errors.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
/* convert from UTF-8 encoded HTML-Pages -> internal Java String Format */
public static String convertFromUTF8(String s) {
String out = null;
try {
byte []encodable = s.getBytes();
out = new String(encodable, "windows-31j");
byte []outBA = out.getBytes("windows-31j");
} catch (java.io.UnsupportedEncodingException e) {
return null;
}
return out;
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
None as such
(Incident Review ID: 311619)
======================================================================