thanks for your help. Thank you Monal and thank you Wang Jun! At last I resolve my problem. Though I can set the encoding in eclipse, the simplist way may be to open the eclipse.ini file in eclipse's directory and add "- Dfile.encoding=UTF-8". Then all things done in eclipse are encoded by UTF-8 by default. Thanks for your enthusiastic help!
在07-1-9,Jun Wang <[EMAIL PROTECTED]> 写道:
Zhang, There are two type of different encoding. 1. Java source file encoding. Eclipse default to a platform-specific encoding(see https://bugs.eclipse.org/bugs/show_bug.cgi?id=108668 ). You may check your file encoding by right click the project property menu 2. Java runtime encoding. (see http://java.sun.com/javase/6/docs/technotes/guides/intl/encoding.doc.html ) you may check it by running following code OutputStreamWriter out = new OutputStreamWriter(new ByteArrayOutputStream()); System.out.println(out.getEncoding()); If these 2 type of encoding are different, it would cause your problem. sometime it happens when you copy and paste text from internet which is UTF-8 at most time. and your OS is a native encoding for example GB2312. Try run as your aspectj application with vm parameter - Dfile.encoding=UTF-8. and redirect output to a file as Monal suggested . hope it helps. Thanks --John J. Wang On 1/8/07, Monal Daxini <[EMAIL PROTECTED] > wrote: > > Zhang, > > What is the default character set for files created in your Eclipse? > > Set it to UTF-8 or UTF-16, and then specify the ajc compiler to let it > know what the source file encoding is. > > ajc -encoding UTF-8 or > ajc -encoding UTF-16 > You can specify the encoding option through AJDT. > > This is similar to the behavior of javac. > > You may already know this, but System.out.println output may work fine > in the console output of Eclipse, but may not work if your command console > (cmd windows) does not support unicode or multi-byte character. > > So, ususally I write the output to a file using java's output stream > with explicit specification of the encoding. > > Monal > > > > > On 1/8/07, Heping Zhang <[EMAIL PROTECTED] > wrote: > > > > > > Mr. Webster, > > > > Thanks for your reply. I use aspectj-1.5.3 and build the project in > > elipse 3.2.0. I build a new aspectj project, then add a test.javaclass to the src folder, which include the "main" method and println some > > Chinese character. But the output seems encoded incorrectly. And just as you > > presume, after I converted the project to a java project using aspectj tools > > in eclipse, the output became correct. In the aspectj project, I have tried > > " System.out.println(new String(s1.getBytes("gbk"), "utf-8"));", " > > System.out.println("unicode: " + new > > String("你好".getBytes("unicode")));" and and so forth. But they did not work > > as I except. Tht result still incorrect. I also have tried set the > > "non-standard compiler options" in aspectj compiler panel to "-encoding GBK" > > but it did not work, too. I worked on this problem for nearly two days and > > now I do not what I can do on earth. Can you help me? > > > > Thank you very much! > > > > Heping Zhang > > > > > > 2007/1/8, Matthew Webster <[EMAIL PROTECTED]>: > > > > > > > > > How are you building your application? Which version of AspectJ are > > > you using? I presume you get the expected output when you application is > > > compiled with javac (or equivalent)? > > > > > > Matthew Webster > > > AOSD Project > > > Java Technology Centre, MP146 > > > IBM Hursley Park, Winchester, SO21 2JN, England > > > Telephone: +44 196 2816139 (external) 246139 (internal) > > > Email: Matthew Webster/UK/IBM @ IBMGB, [EMAIL PROTECTED] > > > http://w3.hursley.ibm.com/~websterm/<http://w3.hursley.ibm.com/%7Ewebsterm/%02> > > > > > > > > > *"Heping Zhang" <[EMAIL PROTECTED]> * > > > Sent by: [EMAIL PROTECTED] > > > > > > 06/01/2007 13:11 Please respond to > > > [email protected] > > > > > > To > > > [email protected] cc > > > > > > Subject > > > [aspectj-users] help! problem about encoding > > > > > > > > > > > > > > > > > > > > > > > > > > > hi, > > > In aspectj project when I use System.out.println("something"); and > > > that "something" is not English words, the output is not encoded correctly. > > > For example, I want print "你好你好" but get "浣�濂戒��濂�". Can someone help me? > > > _______________________________________________ > > > aspectj-users mailing list > > > [email protected] > > > https://dev.eclipse.org/mailman/listinfo/aspectj-users > > > > > > > > > _______________________________________________ > > > aspectj-users mailing list > > > [email protected] > > > https://dev.eclipse.org/mailman/listinfo/aspectj-users > > > > > > > > > > > > > _______________________________________________ > > aspectj-users mailing list > > [email protected] > > https://dev.eclipse.org/mailman/listinfo/aspectj-users > > > > > > > > _______________________________________________ > aspectj-users mailing list > [email protected] > https://dev.eclipse.org/mailman/listinfo/aspectj-users > > > _______________________________________________ aspectj-users mailing list [email protected] https://dev.eclipse.org/mailman/listinfo/aspectj-users
_______________________________________________ aspectj-users mailing list [email protected] https://dev.eclipse.org/mailman/listinfo/aspectj-users
