Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4256423
Votes 0
Synopsis default encoding in String(byte[]) doesn't match file.encoding
Category java:char_encodings
Reported Against 1.1.8
Release Fixed
State 11-Closed, Not a Defect, bug
Priority: 4-Low
Related Bugs 4310802
Submit Date 22-JUL-1999
Description





To execute code, use this command:
"java -Dfile.encoding=iso-8859-2 ErrorInEncoding":
----------------------------------------------------------------
import java.io.*;
import java.util.*;

public class ErrorInEncoding {
 static public void main(String[] args)
    throws UnsupportedEncodingException,IOException
 {
  String smallCzechLetters =
  "a\u00e1bc\u010dd\u010fe\u00e9\u011bfghi\u00edjklmn\u0148o\u00f3pqr\u0159s\u0161t\u0165u\u00fa\u016fvwxy\u00fdz\u017e";
 // get 8-bit chars in iso-8859-2
 byte [] ISO2bytes = smallCzechLetters.getBytes("iso-8859-2");
 // convert them
 String explicit = new String(ISO2bytes,"iso-8859-2");
 String implicit = new String(ISO2bytes);
 // compare them
 System.out.println((smallCzechLetters.equals(explicit)?"Match":"Not match"));
 System.out.println((smallCzechLetters.equals(implicit)?"Match":"Not match"));
 }
}
------------------------------------------------------------------
This will produce output "Match, Not match", so default encoding
used in String constructor is not matching the encoding specified
with -Dfile.encoding.

This bugs is in SUN JDK1.1.8 on WinNT,
it is not in  customer  JDK1.1.6 on AIX
and is not in  customer .org JDK1.1.7v1a on Linux
others I haven't tried.
(Review ID: 63197) 
======================================================================
Work Around




No workaround
======================================================================
Evaluation
file.encoding is intended to reflect the platform encoding; it is not meant to be set from the command line.
  xxxxx@xxxxx   1999-07-26
Comments
  
  Include a link with my name & email   

Submitted On 16-NOV-2002
badarycz
Evaluation is rather strange for me. What does "platform 
encoding" really mean? IMO impossibility of changing platform 
encoding is very unconvenient and unflexible. I had a lot of 
trouble with it.   



PLEASE NOTE: JDK6 is formerly known as Project Mustang