<!--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;
}
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;
}
本文提供了一个将中文字符转换为Unicode格式的Java方法实现,包括处理特定范围内的中文字符。
656

被折叠的 条评论
为什么被折叠?



