中文字符级转换

来源:互联网 发布:淘宝上怎么买淘宝小号 编辑:程序博客网 时间:2024/06/15 13:37
 1 public class Chinese { 2   public static String toUnicode(String strvalue) { 3     try { 4       if (strvalue == null) { 5         return null; 6       } 7       else { 8         strvalue = new String(strvalue.getBytes("GBK"), "ISO8859_1"); 9         return strvalue;10       }11     }12     catch (Exception e) {13       return "";14     }15   }16   17   public static String toChinese(String strvalue) {18     try {19       if (strvalue == null) {20         return "";21       }22       else {23         strvalue = new String(strvalue.getBytes("ISO8859_1"), "GBK");24         return strvalue;25       }26     }27     catch (Exception e) {28       return "";29     }30   }31   32   public static String chinese(String a) {33     try {34       return new String(a.getBytes("ISO-8859-1"));35     }36     catch (UnsupportedEncodingException ex) {37       return null;38     }39   }40 }

 


<script type="text/javascript"><!--google_ad_client = "ca-pub-1944176156128447";/* cnblogs 首页横幅 */google_ad_slot = "5419468456";google_ad_width = 728;google_ad_height = 90;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
原创粉丝点击