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

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