public String cnConverUnicode(String str){
StringBuilder result= new StringBuilder();
for (int i = 0; i < str.length(); i++){
int chr1 = (char) str.charAt(i);
if(chr1>=19968&&chr1<=171941){//汉字范围 \u4e00-\u9fa5 (中文)
sb.append("\\u" + Integer.toHexString(chr1));
}else{
sb.append(str.charAt(i));
}
}
return result.toString();
}
转载于:https://my.oschina.net/u/569652/blog/684129