}
-----------------------------------------------------------------------------------------------------------------------------------------
// 将字符串转换为Unicode码
public static String toUnicode(String zhStr) {
StringBuffer unicode = new StringBuffer();
for (int i = 0; i < zhStr.length(); i++) {
char c = zhStr.charAt(i);
unicode.append("\\u" + Integer.toHexString(c));
}
System.out.println(unicode.toString());
System.out.println(zhStr + "转换为unicode码成功!");
return unicode.toString();
}
public static void main(String[] args) {
toUnicode("你好");
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
原文:http://blog.csdn.net/u010400728/article/details/47657985