From: Ken Hornstein Date: Tue, 3 Dec 2013 04:14:47 +0000 (-0500) Subject: Use pref_encoding() to select the default encoding for all headers. X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/50c8114d791602fcc427c6dc94b55f3226e8a21d?ds=inline;hp=--cc Use pref_encoding() to select the default encoding for all headers. --- 50c8114d791602fcc427c6dc94b55f3226e8a21d diff --git a/sbr/encode_rfc2047.c b/sbr/encode_rfc2047.c index 54a1e088..ac340f71 100644 --- a/sbr/encode_rfc2047.c +++ b/sbr/encode_rfc2047.c @@ -125,14 +125,14 @@ encode_rfc2047(const char *name, char **value, int encoding, * On the encoding we choose, and the specifics of encoding: * * - If a specified encoding is passed in, we use that. - * - If more than 50% of the characters are high-bit, we use base64 - * and encode the whole field as one atom (possibly split). - * - Otherwise, we use quoted-printable. + * - Otherwise, pick which encoding is shorter. + * + * We don't quite handle continuation right here, but it should be + * pretty close. */ if (encoding == CE_UNKNOWN) - encoding = (eightbitcount * 10 / (asciicount + eightbitcount) > 5) ? - CE_BASE64 : CE_QUOTED; + encoding = pref_encoding(asciicount, qpspecialcount, eightbitcount); unfold_header(value, asciicount + eightbitcount);