- line_codepage = charset_from_mimeenc(cfg.line_codepage);
- if (line_codepage == CS_NONE)
- line_codepage = charset_from_xenc(cfg.line_codepage);
- /* If it's still CS_NONE, we should assume direct-to-font. */
-
- /* FIXME: this is a hack. Currently fonts with incomprehensible
- * encodings are dealt with by pretending they're 8859-1. It's
- * ugly, but it's good enough to stop things crashing. Should do
- * something better here. */
- if (line_codepage == CS_NONE)
- line_codepage = CS_ISO8859_1;
+ ucsdata->line_codepage = CS_NONE;
+ if (utf8_override) {
+ const char *s;
+ if (((s = getenv("LC_ALL")) && *s) ||
+ ((s = getenv("LC_CTYPE")) && *s) ||
+ ((s = getenv("LANG")) && *s)) {
+ if (strstr(s, "UTF-8"))
+ ucsdata->line_codepage = CS_UTF8;
+ }
+ }
+
+ /*
+ * Failing that, line_codepage should be decoded from the
+ * specification in conf.
+ */
+ if (ucsdata->line_codepage == CS_NONE)
+ ucsdata->line_codepage = decode_codepage(linecharset);
+
+ /*
+ * If line_codepage is _still_ CS_NONE, we assume we're using
+ * the font's own encoding. This has been passed in to us, so
+ * we use that. If it's still CS_NONE after _that_ - i.e. the
+ * font we were given had an incomprehensible charset - then we
+ * fall back to using the D800 page.
+ */
+ if (ucsdata->line_codepage == CS_NONE)
+ ucsdata->line_codepage = font_charset;
+
+ if (ucsdata->line_codepage == CS_NONE)
+ ret = 1;