Public Staticstring GetEncoding (String str) {string encode= "GB2312"; Try { if(Str.equals (NewString (str.getbytes (encode), encode))) {String s=encode; returns; } } Catch(Exception Exception) {} encode= "Iso-8859-1"; Try { if(Str.equals (NewString (str.getbytes (encode), encode))) {String S1=encode; returnS1; } } Catch(Exception exception1) {} encode= "UTF-8"; Try { if(Str.equals (NewString (str.getbytes (encode), encode))) {String s2=encode; returnS2; } } Catch(Exception exception2) {} encode= "GBK"; Try { if(Str.equals (NewString (str.getbytes (encode), encode))) {String S3=encode; returnS3; } } Catch(Exception exception3) {}return""; }
String encode = "Iso-8859-1"; Apply the extend try { if (Customer.equals (new String) ( Customer.getbytes (encode), encode )) {new String (customer.getbytes (encode), "Utf-8"); } Catch (Exception exception1) { }
Java Judgment string What encoding type