public static String charsetName(final String encoding)
    {
        final String charsetName = STD_CHARSETS.get(encoding);
        if (null != charsetName)
        {
            return "java.nio.charset.StandardCharsets." + charsetName + ".name()";
        }
        else
        {
            return "\"" + (Charset.isSupported(encoding) ? Charset.forName(encoding).name() : encoding) + "\"";
        }
    }
Code to fetch the name of the {@link Charset} given the encoding.

@param encoding as a string name (eg. UTF-8).
@return the code to fetch the associated Charset name.
sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/java/JavaUtil.java