标签:
public class T { public static void main(String[] args) { String s = "java 中文编码"; System.out.println(string2Unicode(s)); } public static String string2Unicode(String string) { StringBuffer unicode = new StringBuffer(); for (int i = 0; i < string.length(); i++) { // 取出每一个字符 char c = string.charAt(i); // 转换为unicode unicode.append("\\u" + Integer.toHexString(c)); } return unicode.toString(); } }
标签:
原文地址:http://www.cnblogs.com/apache-x/p/5498736.html