Duplicate :
|
|
Duplicate :
|
|
Duplicate :
|
FULL PRODUCT VERSION : java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) ADDITIONAL OS VERSION INFORMATION : Microsoft Windows XP [Version 5.1.2600] EXTRA RELEVANT SYSTEM CONFIGURATION : Using English version of Windows. Default locale is "en" A DESCRIPTION OF THE PROBLEM : Enclosed program does round-trip conversion of a string from default encoding to SJIS, and then back. When "ABC" is processed it correctly comes back as "ABC". When a single character string is processed, it comes back as an empty string. STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : Run provided Java program EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - Printed output should be: roundTrip(A)=A roundTrip(ABC)=ABC ACTUAL - Actual output is: roundTrip(A)= roundTrip(ABC)=ABC REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- package gcr.db.test; import java.nio.*; import java.nio.charset.*; /** * Demonstrates apparent bug in SJIS encoding. */ public class SjisBug { public static void main(String[] args) { System.out.println("roundTrip(A)="+roundTrip("A")); // Gets empty string ! System.out.println("roundTrip(ABC)="+roundTrip("ABC")); // Gets ABC, as expected. } static String roundTrip(String str) { Charset cs=Charset.forName("SJIS"); return cs.decode(cs.encode(str)).toString(); } } ---------- END SOURCE ---------- ###@###.### 2004-11-18 04:18:09 GMT
|