zoukankan      html  css  js  c++  java
  • 判断字符串的编码

    /** 

    •      * 判断字符串的编码 
    •      * 
    •      * @param str 
    •      * @return 
    •      */  
    •     public static String getEncoding(String str) {  
    •         String encode = "GB2312";  
    •         try {  
    •             if (str.equals(new String(str.getBytes(encode), encode))) {  
    •                 String s = encode;  
    •                 return s;  
    •             }  
    •         } catch (Exception exception) {  
    •         }  
    •         encode = "ISO-8859-1";  
    •         try {  
    •             if (str.equals(new String(str.getBytes(encode), encode))) {  
    •                 String s1 = encode;  
    •                 return s1;  
    •             }  
    •         } catch (Exception exception1) {  
    •         }  
    •         encode = "UTF-8";  
    •         try {  
    •             if (str.equals(new String(str.getBytes(encode), encode))) {  
    •                 String s2 = encode;  
    •                 return s2;  
    •             }  
    •         } catch (Exception exception2) {  
    •         }  
    •         encode = "GBK";  
    •         try {  
    •             if (str.equals(new String(str.getBytes(encode), encode))) {  
    •                 String s3 = encode;  
    •                 return s3;  
    •             }  
    •         } catch (Exception exception3) {  
    •         }  
    •         return "";  
    •     }  
    • }  
  • 相关阅读:
    几个工具类
    C#学习-程序集和反射
    Unity学习-鼠标的常用操作(八)
    Unity学习-碰撞检测(七)
    Unity学习-摄像机的使用(六)
    Unity学习-地形的设置(五)
    Unity学习-预制(四)
    Unity学习-元素类型(三)
    Unity学习-软件的基本操作(二)
    Unity学习-工具准备(一)
  • 原文地址:https://www.cnblogs.com/lbjz/p/3365292.html
Copyright © 2011-2022 走看看