]> diplodocus.org Git - nmh/commitdiff
Use pref_encoding() to select the default encoding for all headers.
authorKen Hornstein <kenh@pobox.com>
Tue, 3 Dec 2013 04:14:47 +0000 (23:14 -0500)
committerKen Hornstein <kenh@pobox.com>
Tue, 3 Dec 2013 04:14:47 +0000 (23:14 -0500)
sbr/encode_rfc2047.c

index 54a1e08881efedbbe1731985b15005aaa52986f1..ac340f71cced69ee6ecca5a924e89ac0c6292f89 100644 (file)
@@ -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);