首页 > 编程语言 > 详细

java实现中文,unicode互相转换

时间:2015-03-03 11:38:01      阅读:168      评论:0      收藏:0      [点我收藏+]
//中文转换成unicode码值
String str = "抢购人数太多,请稍后重试!" ;
char[]arChar=str.toCharArray();
int iValue=0;
String uStr="" ;
for(int i=0;i<arChar. length;i++){
iValue=( int)str.charAt(i);          
     if(iValue<=256){
          uStr+= "\\"+Integer. toHexString(iValue);
     } else{
          uStr+= "\\u"+Integer. toHexString(iValue);
     }
}

//unicode码值转换成中文
String str = "抢购人数太多,请稍后重试!" ;
char[]arChar=str.toCharArray();
int iValue=0;
String uStr= "";
for( int i=0;i<arChar. length;i++){
     iValue=( int)str.charAt(i);          
     if(iValue<=256){
          uStr+= "\\"+Integer. toHexString(iValue);
     } else{
          uStr+= "\\u"+Integer. toHexString(iValue);
     }
}

java实现中文,unicode互相转换

原文:http://blog.csdn.net/lluohuih/article/details/44036011

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!