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: 4234961
Votes 3
Synopsis Windows NT filename text encoding doesn't handle illegal chars
Category java:char_encodings
Reported Against 1.1.8
Release Fixed
State 11-Closed, Will Not Fix, bug
Priority: 5-Very Low
Related Bugs 4228207 , 4313884
Submit Date 03-MAY-1999
Description


Background:

If Windows NT's file system encounters a file with illegal characters (eg, \ / etc) it converts the illegal chars to   0xF0xx. . .

    [reflects correction vs. original, based on later user comment:  "I said the  characters are 0xFFxx, but they're actually 0xF0xx."]

Files with illegal characters can be generated on the Mac.

Somewhere in the Java encoding, these special characters get converted to '?' (0x3F).  This makes it impossible to open the file with an
InputStream or Reader  customer ...

Code:

This application just uses a FileDialog to select a file.  It then tries to open it with a FileReader which will fail with a FileNotFoundException.
You'll need to create a file with illegal chars yourself.

import java.awt.*;
import java.io.*;

public class TrivialApplication {

        public static void main(String args[]) 
	{
		Frame f = new Frame();
		f.pack();
		
		FileDialog d = new FileDialog(f);
		d.setVisible(true);
		
		String javaPath;
		System.out.println(javaPath = d.getFile());
		
		try
		{
			FileReader inStream = new FileReader(javaPath);
			inStream.close();
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
	}
}

Sample output:

[d:\araxidev\javahacks\illegalntchartest]java -version
java version "1.1.8"

[d:\araxidev\javahacks\illegalntchartest]java -fullversion
java full version "JDK1.1.8K"

[d:\araxidev\javahacks\illegalntchartest]java -classpath d:\araxioem\private\jdk
1.1.8\lib\classes.zip;AppClasses.jar TrivialApplication
90??? fromHell.pdf
java.io.FileNotFoundException: 90??? fromHell.pdf
        at java.io.FileInputStream.<init>(FileInputStream.java:56)
        at java.io.FileReader.<init>(FileReader.java:35)
        at TrivialApplication.main(TrivialApplication.java)
(Review ID: 57670) 
======================================================================
Posted Date : 2006-04-27 22:04:30.0
Work Around




None.
======================================================================
Evaluation
The new character converter SPI, rfe #4313884 for merlin/jdk1.4 provides
public access to a method for setting the substitution char (or chars).
So, for example, it should be possible for an application developer to
implement their own policy with regard to how characters which cannot
be mapped in a given encoding are substituted (or not). 

  xxxxx@xxxxx   12/21/2000
As suggested above, use java.nio.charset.spi to have customized version
of charset.
Posted Date : 2006-04-27 22:04:30.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang