-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.4.0
-
x86
-
windows_2000
Name: dk106046 Date: 08/14/2002
Instead of ?sun.io.MalformedInputException?, garbage is displayed
in the console and in the popup frame while reading bad utf8data.
Problem is seen on: Sun 1.4.0_01-b03 and Sun 1.4.1-beta-b14
Works fine with: Sun 1.3.1_04-b02 and IBM 131 cn131-20020710
Testcase:
//--------------------------------------------------------------------
import java.io.*;
import javax.swing.*;
public class ReadUTF8
{
public static void main(String[] argv)
{
JFrame jf=new JFrame();
JPanel p=new JPanel();
JTextArea t=new JTextArea(10,80);
p.add(t);
jf.getContentPane().add(p);
jf.setSize(800,300);
jf.show();
System.out.println(argv[0]);
try
{
File f=new File(argv[0]);
BufferedReader i=new BufferedReader(
new InputStreamReader(
new FileInputStream(f),"UTF-8"));
String s=i.readLine();
while(s!=null)
{
System.out.println(s);
s=i.readLine();
t.append(s);
t.append("\r\n");
}
}
catch(Exception e)
{
System.out.println(e);
}
}
}
//--------------------------------------------------------------------
[ "testutf8.txt" and "testansi.txt" are available via contact email ]
'java ReadUTF8 testutf8.txt' displays belarussian correctly in the frame
'java ReadUTF8 testansi.txt' results in garbage displaying in the
console and in the popup frame.
This is INCORRECT behavior. Once the utf8 decoder encounters invalid data, the read should exit with sun.io.MalformedInputException, not continue and corrupt the data.
======================================================================
Instead of ?sun.io.MalformedInputException?, garbage is displayed
in the console and in the popup frame while reading bad utf8data.
Problem is seen on: Sun 1.4.0_01-b03 and Sun 1.4.1-beta-b14
Works fine with: Sun 1.3.1_04-b02 and IBM 131 cn131-20020710
Testcase:
//--------------------------------------------------------------------
import java.io.*;
import javax.swing.*;
public class ReadUTF8
{
public static void main(String[] argv)
{
JFrame jf=new JFrame();
JPanel p=new JPanel();
JTextArea t=new JTextArea(10,80);
p.add(t);
jf.getContentPane().add(p);
jf.setSize(800,300);
jf.show();
System.out.println(argv[0]);
try
{
File f=new File(argv[0]);
BufferedReader i=new BufferedReader(
new InputStreamReader(
new FileInputStream(f),"UTF-8"));
String s=i.readLine();
while(s!=null)
{
System.out.println(s);
s=i.readLine();
t.append(s);
t.append("\r\n");
}
}
catch(Exception e)
{
System.out.println(e);
}
}
}
//--------------------------------------------------------------------
[ "testutf8.txt" and "testansi.txt" are available via contact email ]
'java ReadUTF8 testutf8.txt' displays belarussian correctly in the frame
'java ReadUTF8 testansi.txt' results in garbage displaying in the
console and in the popup frame.
This is INCORRECT behavior. Once the utf8 decoder encounters invalid data, the read should exit with sun.io.MalformedInputException, not continue and corrupt the data.
======================================================================
- duplicates
-
JDK-4646959 REGRESSION: UTF-8 decoder silently accepts illegal UTF-8 byte sequences
-
- Closed
-