public Charset charsetForName(String charsetName) {
        if (name2charset == null)
            init();

        // get charset instance for given name (case insensitive)
        Charset c = (Charset)name2charset.get(charsetName.toLowerCase());
        try {
            if (c != null)
                c = (Charset)c.getClass().newInstance();
        } catch (Exception e) {
            // if we can't get an instance, we don't.
            c = null;
        }
        return c;
    }