-
Bug
-
Resolution: Fixed
-
P3
-
1.2.0, 1.2.1, 1.2.2, 1.3.0, 1.3.1
-
07
-
generic, x86
-
generic, windows_nt, windows_2000
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2023589 | 1.4.0 | Sundararajan Athijegannathan | P3 | Resolved | Fixed | rc1 |
Name: mr33420 Date: 10/29/98
Under Windows NT4.0 (sp3) (cp1252) with an NTFS file system I cannot create nor
correctly list files containing Unicode characters. NTFS
supports Unicode file names. The following code demonstrates the problem:
================= cut here =================
import java.io.*;
public class test {
public static void main(String[] args) {
String fname = "hi\u3040\u3041mom"; // a file name with unicode chars
File dir = new File(args[0]);
File f = new File(dir, fname);
listFiles(dir);
try {
System.out.println("trying to create file...");
FileOutputStream out = new FileOutputStream(f);
out.close();
System.out.println("done.");
} catch (IOException e) {
System.out.println("ERROR: " + e);
}
listFiles(dir);
}
public static void listFiles(File dir) {
System.out.println("Contents of: " + dir.getAbsolutePath());
String[] list = dir.list();
for(int i = 0; i < list.length; i++) {
String name = list[i];
System.out.print(name + " :");
for(int j = 0; j < name.length(); j++) {
System.out.print(" 0x" + Integer.toHexString(name.charAt(j)));
}
System.out.println("");
}
System.out.println("");
}
}
================= cut here =================
If I run the program with JDK1.2 RC1 in an empty directory I get:
Contents of: c:\unitest
trying to create file...
ERROR: java.io.FileNotFoundException: c:\unitest\hi??mom (The filename, director
y name, or volume label syntax is incorrect)
Contents of: c:\unitest
To show that I can in fact create files with Unicode characters I can run
this program with Microsoft's VM (jview) and get the following output:
Contents of: c:\unitest
trying to create file...
done.
Contents of: c:\unitest
hi??mom : 0x68 0x69 0x3040 0x3041 0x6d 0x6f 0x6d
Note that the file has been created with the correct Unicode chars.
Now run the program again with JDK1.2 RC1 VM and note that listing the
files in the directory looses information about the correct Unicode
characters in the file name:
Contents of: c:\unitest
hi??mom : 0x68 0x69 0x3f 0x3f 0x6d 0x6f 0x6d
trying to create file...
ERROR: java.io.FileNotFoundException: c:\unitest\hi??mom (The filename, director
y name, or volume label syntax is incorrect)
Contents of: c:\unitest
hi??mom : 0x68 0x69 0x3f 0x3f 0x6d 0x6f 0x6d
(Review ID: 41554)
======================================================================
Name: krT82822 Date: 06/04/99
Using the following code to list my test directory which contains Chinese, Japanese, and Korean characters in the file name. Always failed to list some or both while with Chinese/Japanese/Korean environment. My software environment is WINNT 4.0(build 1381) with SP4 plus RichWin97 build 3330 version 4.0.231298.
The JavaCode is:
import java.io.*;
import java.util.*;
public class test {
public static void main(String[] args) {
System.out.println("Locale is: " + Locale.getDefault());
for (int i=0; i<args.length; i++) {
File f = new File(args[i]);
proc(f);
}
System.out.println("End.");
}
public static void proc(File f) {
String lst[] = f.list();
if (lst == null || lst.length == 0) {
System.out.print(f);
System.out.println("--->Empty");
return ;
} else {
//System.out.println(":");
}
for(int i=0; i<lst.length ; i++) {
//System.out.println(lst[i]);
File g = new File(f, lst[i]);
System.out.print (g);
if (g.isDirectory()) {
System.out.println("-->Directory.");
proc(g);
} else if (g.isFile()) {
System.out.print("-->File");
if (g.exists()) {
System.out.println("-->Exists.");
} else {
System.out.println("-->Failed!");
}
} else {
System.out.println("-->XXXXXXX.");
}
}
}
}
The result without RichWin is:
Locale is: en_US
d:\test\j\jse206007-->Directory.
d:\test\j\jse206007\chinese-->Directory.
d:\test\j\jse206007\chinese\321??.doc-->XXXXXXX.
d:\test\j\jse206007\japan-->Directory.
d:\test\j\jse206007\japan\???????????.obd-->XXXXXXX.
d:\test\j\jse206007\korea-->Directory.
d:\test\j\jse206007\korea\SW??.XLS-->XXXXXXX.
d:\test\j\jse206007\korea\?????.com-->XXXXXXX.
d:\test\j\jse206007\macrotrp-->Directory.
d:\test\j\jse206007\macrotrp\2000??.XLS-->XXXXXXX.
d:\test\j\jse206007\specase-oemchar-->Directory.
d:\test\j\jse206007\specase-oemchar\??-->XXXXXXX.
1.2.10--->Empty
1.2.11--->Empty
1.2.12--->Empty
End.
With RichWin (GB)
Locale is: zh_CN
d:\test\j\jse206007-->Directory.
d:\test\j\jse206007\chinese-->Directory.
d:\test\j\jse206007\chinese\321エ??・doc-->File-->Exists.
d:\test\j\jse206007\japan-->Directory.
d:\test\j\jse206007\japan\???????????.obd-->XXXXXXX.
d:\test\j\jse206007\korea-->Directory.
d:\test\j\jse206007\korea\SW?Tヤ・XLS-->File-->Exists.
d:\test\j\jse206007\korea\?????.com-->XXXXXXX.
d:\test\j\jse206007\macrotrp-->Directory.
d:\test\j\jse206007\macrotrp\2000ト・・XLS-->File-->Exists.
d:\test\j\jse206007\specase-oemchar-->Directory.
d:\test\j\jse206007\specase-oemchar\?eイE-->File-->Exists.
1.2.10--->Empty
1.2.11--->Empty
1.2.12--->Empty
End.
with RichWin Japanese (SHIFT JIS)
Locale is: ja_JP
d:\test\j\jse206007-->Directory.
d:\test\j\jse206007\chinese-->Directory.
d:\test\j\jse206007\chinese\321?j??.doc-->File-->Exists.
d:\test\j\jse206007\japan-->Directory.
d:\test\j\jse206007\japan\アウエヤオヤヤユユユア.obd-->XXXXXXX.
d:\test\j\jse206007\korea-->Directory.
d:\test\j\jse206007\korea\SW????.XLS-->File-->Exists.
d:\test\j\jse206007\korea\?????.com-->XXXXXXX.
d:\test\j\jse206007\macrotrp-->Directory.
d:\test\j\jse206007\macrotrp\2000?~??.XLS-->File-->Exists.
d:\test\j\jse206007\specase-oemchar-->Directory.
d:\test\j\jse206007\specase-oemchar\??-->XXXXXXX.
1.2.10--->Empty
1.2.11--->Empty
1.2.12--->Empty
End.
with Rich Win Korean (KSC)
Locale is: ko_KR
d:\test\j\jse206007-->Directory.
d:\test\j\jse206007\chinese-->Directory.
d:\test\j\jse206007\chinese\321?j??.doc-->File-->Exists.
d:\test\j\jse206007\japan-->Directory.
d:\test\j\jse206007\japan\???????????.obd-->XXXXXXX.
d:\test\j\jse206007\korea-->Directory.
d:\test\j\jse206007\korea\SW????.XLS-->File-->Exists.
d:\test\j\jse206007\korea\ㄴㅁㄹ료ㄷ.com-->File-->Exists.
d:\test\j\jse206007\macrotrp-->Directory.
d:\test\j\jse206007\macrotrp\2000?~??.XLS-->File-->Exists.
d:\test\j\jse206007\specase-oemchar-->Directory.
d:\test\j\jse206007\specase-oemchar\??-->XXXXXXX.
1.2.10--->Empty
1.2.11--->Empty
1.2.12--->Empty
End.
with RichWin Chinese (Big5 JT)
Locale is: zh_CN
d:\test\j\jse206007-->Directory.
d:\test\j\jse206007\chinese-->Directory.
d:\test\j\jse206007\chinese\321댕?.doc-->File-->Exists.
d:\test\j\jse206007\japan-->Directory.
d:\test\j\jse206007\japan\???????????.obd-->XXXXXXX.
d:\test\j\jse206007\korea-->Directory.
d:\test\j\jse206007\korea\SW딡??.XLS-->File-->Exists.
d:\test\j\jse206007\korea\?????.com-->XXXXXXX.
d:\test\j\jse206007\macrotrp-->Directory.
d:\test\j\jse206007\macrotrp\2000쾨깊.XLS-->File-->Exists.
d:\test\j\jse206007\specase-oemchar-->Directory.
d:\test\j\jse206007\specase-oemchar\?{콳-->File-->Exists.
1.2.10--->Empty
1.2.11--->Empty
1.2.12--->Empty
End.
and RichWin UTF8
Locale is: en_US
d:\test\j\jse206007-->Directory.
d:\test\j\jse206007\chinese-->Directory.
d:\test\j\jse206007\chinese\321???.doc-->File-->Exists.
d:\test\j\jse206007\japan-->Directory.
d:\test\j\jse206007\japan\???????????.obd-->XXXXXXX.
d:\test\j\jse206007\korea-->Directory.
d:\test\j\jse206007\korea\SW?D??.XLS-->File-->Exists.
d:\test\j\jse206007\korea\?????.com-->XXXXXXX.
d:\test\j\jse206007\macrotrp-->Directory.
d:\test\j\jse206007\macrotrp\2000????.XLS-->File-->Exists.
d:\test\j\jse206007\specase-oemchar-->Directory.
d:\test\j\jse206007\specase-oemchar\???E-->File-->Exists.
1.2.10--->Empty
1.2.11--->Empty
1.2.12--->Empty
End.
(Review ID: 83922)
======================================================================
Name: krT82822 Date: 02/13/2000
java version "1.2.1"
Classic VM (build JDK-1.2.1-A, native threads)
On Win2000, whenever I try to read files that have Arabic characters in their
name, I get an exception stating that the file is not found. I traced the code,
and found that the Arabic characters in the file name are replaced by '?' (hex
3F). This changes the file name to a wrong string which does not refer to the
concerned file. It wasn't the case when I used JDK1.2.1 on WinNT or Win95. The
same code runs properly on those platforms. I traced into the JDK code itself
and read some comments stating that the file name is returned by the native
system, i.e. the conversion of the characters to '?' is done by the native
code, not by the java classes. Just for reference, I don't have any problem in
reading the Arabic text contained in the files, the problem is only related to
the file name.
public static void main(String args[]) {
File path = new File(testFile.getParent());
String fileName;
String fileList[];
try {
fileList = path.list();
fileName = fileList[0];// if the file name contains Arabic characters
// these characters will be replaced by '?'
}
catch(Exception e) {
System.out.println("Exception in main() " + e);
}
}
(Review ID: 101181)
======================================================================
Name: yyT116575 Date: 01/22/2001
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)
I'm trying to pass Unicode string arguments (file names) to my Java application from a native Win32 app. The native app is strictly Unicode (using wWinMain and exlusively _TCHAR and L"..." string literals). I'm calling Java like this:
// testing with U+FB56 ARABIC LETTER PEH ISOLATED
wstring params = L"Here comes a Unicode char: \xfb\x56";
ShellExecute(0, 0, L"javaw.exe", params.c_str(), 0, SW_SHOWNORMAL);
My Java main method sees the arabic Peh as a "?" (ASCII 63, hex 3f). Some
Unicode chars actually work, though. I tested with U+20AC (euro symbol), and it worked fine.
(Review ID: 115565)
======================================================================
- backported by
-
JDK-2023589 java.io: Cannot create files with full Unicode names (Win32/NT)
-
- Resolved
-
- duplicates
-
JDK-4498715 filename with japanese characters
-
- Closed
-
-
JDK-4302971 java.io: Use wide filesystem APIs under Win32
-
- Closed
-
-
JDK-4495783 File not found exception when trying to access macintosh files on NT
-
- Closed
-
- relates to
-
JDK-4778561 REGRESSION:General exhaustive test of win32 pathname handling
-
- Resolved
-
-
JDK-4845710 File constructor does not properly translate unicode to platform encoding
-
- Closed
-
(1 relates to)