您的位置:首页 > 其它

汉字转化为unicode

2010-08-31 15:32 211 查看
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();
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: