JDK-4256423 : default encoding in String(byte[]) doesn't match file.encoding
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio.charsets
  • Affected Version: 1.1.8
  • Priority: P4
  • Status: Closed
  • Resolution: Not an Issue
  • OS: windows_nt
  • CPU: x86
  • Submitted: 1999-07-22
  • Updated: 1999-07-26
  • Resolved: 1999-07-26
Related Reports
Relates :  
Description

Name: et89391			Date: 07/22/99



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 IBM JDK1.1.6 on AIX
and is not in Blackdown.org JDK1.1.7v1a on Linux
others I haven't tried.
(Review ID: 63197) 
======================================================================

Comments
WORK AROUND Name: et89391 Date: 07/22/99 No workaround ======================================================================
11-06-2004

EVALUATION file.encoding is intended to reflect the platform encoding; it is not meant to be set from the command line. norbert.lindenberg@Eng 1999-07-26
26-07-1999