Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MacOS 10.4.11 Character problem



Greg, thank for your kindly help.

There is a method can solved this problem temporarily before this bug fixed.

----- code ----------------
File file = new File("/Users/imageworks/Desktop/表示履歴.jpg");
String[] command = {"ditto", "-ck", "--sequesterRsrc",filename, "/Users/imageworks/Desktop/zhangh.zip"};
StringBuffer sb = new StringBuffer();
sb.append("#!" + System.getProperty("line.separator"));
for(String s : command){
sb.append(s);
sb.append(" ");
}
PrintStream ps= new PrintStream(new FileOutputStream("/Users/imageworks/Desktop/zhang.sh"));
ps.write(sb.toString().getBytes("UTF8"));
ps.flush();
String[] command1 = {"sh", "/Users/imageworks/Desktop/zhang.sh"};
Process child = Runtime.getRuntime().exec(command1);
........
------------------ code ------------------------


Best regards.
Zhang zehao.

----- Original Message ----- From: "Greg Guerin" <email@hidden>
To: "list Java-dev" <email@hidden>
Sent: Thursday, August 21, 2008 10:04 AM
Subject: Re: MacOS 10.4.11 Character problem



zhangzehao wrote:

And, using "java -Dfile.encoding=UTF8" can resolve my problem,
but I set the file.encoding "System.setProperty('file.encoding', 'UTF8')" in my app, that can not be usefull.
What the difference bettween these?

The difference is due to timing, specifically, the point in time when the value of "file.encoding" is used.


The JVM executes a significant amount of Java code before your main() method is ever called. That code happens to use the value of the "file.encoding" property to load a class and store it in a static variable. After that point, the value of "file.encoding" is not read again, so changing it in your app's main() will have no effect.

You can find where "file.encoding" is used by searching the source of the JVM classes for "file.encoding". For example, there is a use in java.nio.charset.Charset.

There is another use in the class java.lang.ProcessImpl, and it may be related to the bug you're seeing when 'ditto' is exec()'ed. Look at the method getEncodedBytes(), and also see the other methods that call it. I could be mistaken, but getEncodedBytes() just seems wrong to me, not least because it doesn't account for "file.encoding" values other than "MacRoman". Or maybe this code isn't used any more, or ProcessImpl's source is wrong.


In any case, I recommend filing a bug-report on the exact problem you are seeing.


  http://developer.apple.com/bugreporter

Be sure to include steps to reproduce the problem for someone who might not know anything about Chinese writing systems. You might have to write a Java program as the file generator using Unicode escapes for the Chinese characters (\uxxxx). I had to do that once with a bug that involved multiple accented characters in a row, because it was only the Java code that malfunctioned.


You can get the source for the Java API classes by logging into ADC and downloading the Developer Documentation from Downloads > Java.


  http://connect.apple.com/


PS: Is the java 1.5 DP7 == 1.5.0_07?

Not necessarily. "DP7" means "Developer Preview 7". This just identifies it as the seventh preview of that product release cycle from Apple.


1.5.0_07 identifies the Sun build of the JVM. If there were enough DP builds of 1.5.0_13, the seventh preview would be called "DP7", even though it's for the 1.5.0_13 JVM build.

You might want to look at this:
  http://developer.apple.com/technotes/tn2002/tn2110.html

Notice the lack of correlation between Java Release numbering, and "java.version" or "java.runtime.version" numbering. A similar thing happens with DP numbering.

  -- GG


_______________________________________________ Do not post admin requests to the list. They will be ignored. Java-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden
References: 
 >Re: MacOS 10.4.11 Character problem (From: Greg Guerin <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.