utf8文件中能不能直接写汉字?
我这样做不行,utf8文件中要用的汉字怎么办,用resourceBundle?
public class test
{
public static void main(String[] args)
{
System.out.println("Hello World 中言语 !");
}
}
C:\ww>javac test.java
test.java:5: warning: unmappable character for encoding GBK
System.out.println("Hello World 涓█璇? !");
^
1 warningC:\ww>java test
Hello World 涓█璇? !
我这样做不行,utf8文件中要用的汉字怎么办,用resourceBundle?
public class test
{
public static void main(String[] args)
{
System.out.println("Hello World 中言语 !");
}
}
C:\ww>javac test.java
test.java:5: warning: unmappable character for encoding GBK
System.out.println("Hello World 涓█璇? !");
^
1 warningC:\ww>java test
Hello World 涓█璇? !
String str3 = new String(str1.getBytes(),"GBK");
System.out.println(str3);
用resourceBundle到是可以解决,但有点麻烦。
直接这样写System.out.println("Hello World !"+"\u54ac\u7259\u5207\u9f7f");,又影响阅读不知道大家有没有什么好办法编辑utf8文件?
又要看得懂,又要是utf8编码的方法?
-----------------------
这也可行。但每次为几个汉字就要native2ascii也太麻烦了。