Java Judgment string What encoding type

Source: Internet
Author: User

      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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.