Line policy
MIME message consists of lines for both the headers and the body. Each line ends with the carriage returna and line feed characters. The RFC specification imposes two limits for the line lengths: the recommended of 78 characters and the mandatory of 998 characters in a line. The limitations do not count the CR and LF characters, so in total that is 80 and 1000 characters per line.
Implementation
The enumeration mailio::codec::line_len_policy_t
holds the mentioned two limitations.
However, in practice one might found MIME messages with lines longer than 1000 characters. For that reason, there is another
possibility NONE
for this enumeration, which does not control the line length. (Its value
is the maximum unsigned integer.)
Folding
The message body is formatted for the given line length by truncating a string at the desired length. When the content is Ascii (seven bit), then the string is simply split. If the encoding is Base64, then it does also not matter where the string is split. For the Quoted printable, a word which is split has the padding equal character at the end of line.
Since a header can be also longer then the line policy, in such cases the lines other than the first one are folded with several whitespace characters. It is necessary that for a single header the number of folding whitespaces is the same.