+ /*
+ * If the content is text and didn't specify a character set,
+ * we need to figure out which one was used.
+ */
+
+ if (ct->c_type == CT_TEXT) {
+ t = (struct text *) ct->c_ctparams;
+ if (t->tx_charset == CHARSET_UNSPECIFIED) {
+ CI ci = &ct->c_ctinfo;
+ char **ap, **ep;
+
+ for (ap = ci->ci_attrs, ep = ci->ci_values; *ap; ap++, ep++)
+ continue;
+
+ if (contains8bit) {
+ *ap = concat ("charset=", write_charset_8bit(), NULL);
+ } else {
+ *ap = add ("charset=us-ascii", NULL);
+ }
+ t->tx_charset = CHARSET_SPECIFIED;
+
+ cp = strchr(*ap++, '=');
+ *ap = NULL;
+ *cp++ = '\0';
+ *ep = cp;
+ }
+ }
+