+
+/*
+ * This function is to be used to decide which encoding algorithm we should
+ * use if one is not given. Basically, we pick whichever one is the shorter
+ * of the two.
+ *
+ * Arguments are:
+ *
+ * ascii - Number of ASCII characters in to-be-encoded string.
+ * specials - Number of ASCII characters in to-be-encoded string that
+ * still require encoding under quoted-printable. Note that
+ * these are included in the "ascii" total.
+ * eightbit - Eight-bit characters in the to-be-encoded string.
+ *
+ * Returns one of CE_BASE64 or CE_QUOTED.
+ */
+
+static int
+prefencoding(int ascii, int specials, int eightbits)
+{
+ /*
+ * The length of the q-p encoding is:
+ *
+ * ascii - specials + (specials + eightbits) * 3.
+ *
+ * The length of the base64 encoding is:
+ *
+ * base64len(ascii + eightbits) (See macro for details)
+ */
+
+ return base64len(ascii + eightbits) < (ascii - specials +
+ (specials + eightbits) * 3) ? CE_BASE64 : CE_QUOTED;
+}