Class RFC2231

  • public class RFC2231
    extends Object
    RFC-2231 specifies how a MIME parameter value, like Content-Disposition's filename, can be encoded to contain arbitrary character sets.
    Florent Guillaume
    • Method Detail

      • percentEscape

        public static void percentEscape​(StringBuilder sb,
                                         String value)
        Does a simple %-escaping of the UTF-8 bytes of the value. Keep only some know safe characters.
        sb - the builder to which escaped chars are appended
        value - the value to escape
      • encodeRFC2231

        protected static void encodeRFC2231​(StringBuilder sb,
                                            String value)
        Encodes a MIME parameter per RFC 2231.

        This implementation always uses UTF-8 and no language.

        sb - the buffer to fill
        value - the value to encode
      • encodeContentDisposition

        public static String encodeContentDisposition​(String filename,
                                                      boolean inline,
                                                      String userAgent)
        Encodes a Content-Disposition header. For some user agents the full RFC-2231 encoding won't be performed as they don't understand it.
        filename - the filename
        inline - true for an inline disposition, false for an attachment
        userAgent - the userAgent
        a full string to set as value of a Content-Disposition header