import java.util.*;
import java.io.*;
public class EncodingDemoUTF8 {
public static void main(String[] args) throws IOException, FileNotFoundException {
PrintWriter output = new PrintWriter("temp.txt", "UTF-8");
output.print("\u6B22\u8FCE Welcome \u03b1\u03b2\u03b3, \u4e2d\u56fd\u8054\u901a, \u62c9\u5361\u62c9");
output.close();
Scanner input = new Scanner(new File("temp.txt"), "UTF-8");
System.out.println(input.nextLine());
}
}
/*
* http://docs.oracle.com/javase/7/docs/api/
* UTF-8, for example, is used only to encode Unicode.
* The native character encoding of the Java programming language is UTF-16. A charset in the Java platform therefore defines a mapping between sequences of sixteen-bit UTF-16 code units (that is, sequences of chars) and sequences of bytes.
*
* 16-bit ASCII
* 5C - \
* so, \u4e2d is represented as %5C4e2d in URL-encoder.
*
*/
java Unicode Issues
最新推荐文章于 2019-02-02 10:05:45 发布