private static String decodeFilename(String filename, Charset charset) {
        Objects.requireNonNull(filename, "'input' String` should not be null");
        Objects.requireNonNull(charset, "'charset' should not be null");
        byte[] value = filename.getBytes(charset);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        int index = 0;
        while (index < value.length) {
            byte b = value[index];
            if (isRFC5987AttrChar(b)) {
                baos.write((char) b);
                index++;
            }
            else if (b == '%' && index < value.length - 2) {
                char[] array = new char[]{(char) value[index + 1], (char) value[index + 2]};
                try {
                    baos.write(Integer.parseInt(String.valueOf(array), 16));
                }
                catch (NumberFormatException ex) {
                    throw new IllegalArgumentException(INVALID_HEADER_FIELD_PARAMETER_FORMAT, ex);
                }
                index+=3;
            }
            else {
                throw new IllegalArgumentException(INVALID_HEADER_FIELD_PARAMETER_FORMAT);
            }
        }
        return baos.toString(charset);
    }
Decode the given header field param as described in RFC 5987.
<p>Only the US-ASCII, UTF-8 and ISO-8859-1 charsets are supported.
@param filename the filename
@param charset the charset for the filename
@return the encoded header field param
@see <a href="https://tools.ietf.org/html/rfc5987">RFC 5987</a>
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/util/ContentDisposition.java