当前位置: 代码迷 >> Web前端 >> JAVA 将汉语转为unicode
  详细解决方案

JAVA 将汉语转为unicode

热度:160   发布时间:2012-10-31 14:37:31.0
JAVA 将中文转为unicode
<!--StartFragment -->
public?String?chinaToUnicode(String?str){?
/***?中文转?unicode?***/
String?result="";
int?len=str.length();
for(int?i=0;i<len;i++){
????????????int?chr1=(char)str.charAt(i);
????????????if(chr1>=19968&&chr1<=171941){
????????????????result+="?\\u"+Integer.toHexString(chr1);
????????????}else{
???????????? result+=str.charAt(i);
????????????}
????????}
return?result;
}
  相关解决方案