Java Charset Create getCanonicalCharset(String charset)

Here you can find the source of getCanonicalCharset(String charset)

Description

get Canonical Charset

License

Open Source License

Declaration

public static String getCanonicalCharset(String charset) 

Method Source Code


//package com.java2s;
import java.nio.charset.Charset;

public class Main {

    public static String getCanonicalCharset(String charset) {
        return Charset.forName(charset).name();
    }//from  w  w w  .  ja va  2s.c  om

    public static String getCanonicalCharset(String charset, String defaultCharset) {
        String result = null;

        try {
            result = getCanonicalCharset(charset);
        } catch (IllegalArgumentException e) {
            if (defaultCharset != null) {
                try {
                    result = getCanonicalCharset(defaultCharset);
                } catch (IllegalArgumentException ee) {
                }
            }
        }

        return result;
    }
}

Related

  1. getCanonicalCharset(String charset)
  2. getCharset()
  3. getCharset()
  4. getCharset(int cpgid, int gcsgid)