Class HeaderLine


  • public class HeaderLine
    extends Encoding
    Ref: http://en.wikipedia.org/wiki/MIME#Encoded-Word http://tools.ietf.org/html/rfc2047 https://jeffreystedfast.blogspot.com/2013/09/time-for-rant-on-mime-parsers.html https://jeffreystedfast.blogspot.com/2013/08/why-decoding-rfc2047-encoded-headers-is.html
    Author:
    susi
    • Constructor Detail

      • HeaderLine

        public HeaderLine()
    • Method Detail

      • encode

        public String encode​(String str)
                      throws EncodingException
        Encode a single header line ONLY. Do NOT include the \r\n. Returns a string of one or more lines including the trailing \r\n. Field-name will not be encoded, must be less than 62 chars. The fieldBody is treated as "unstructured text", which is suitable only for the field names "Subject" and "Comments". We do NOT tokenize into structured fields. To make things easy, we either encode the whole field body as RFC 2047, or don't encode at all. If it's too long for a single line, we encode it, even if we didn't otherwise have to. We don't do quoted-string. This will not split multibyte chars, including supplementary chars, across lines. TODO this will not work for quoting structured text such as recipient names on the "To" and "Cc" lines.
        Overrides:
        encode in class Encoding
        Parameters:
        str - must start with "field-name: ", must have non-whitespace after that
        Throws:
        EncodingException
        See Also:
        Encoding.encode(byte[])