Here you can find the source of getCanonicalCharset(String charset)
public static String getCanonicalCharset(String charset)
//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; } }