汉字转化为unicode

public static String gbkToUnicode(String s) throws Exception { if(s == null) return null; char []chars = s.toCharArray(); StringBuffer result = new StringBuffer(); String temp = ""; for(int i = 0;i < chars.length; i++) { temp = Integer.toHexString((int)chars[i]).toUpperCase(); result.append("//"+"u"); if(temp.length()!=4) { for(int j=0;j<4-temp.length();j++) { result.append("0"); } } result.append(temp); } return result.toString(); }

你可能感兴趣的:(汉字转化为unicode)