+
+ /*
+ * In the platform-independent parts of the code, font_codepage
+ * is used only for system DBCS support - which we don't
+ * support at all. So we set this to something which will never
+ * be used.
+ */
+ font_codepage = -1;
+
+ /*
+ * line_codepage should be decoded from the specification in
+ * cfg.
+ */
+ 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;
+
+ /*
+ * Set up unitab_line, by translating each individual character
+ * in the line codepage into Unicode.
+ */
+ for (i = 0; i < 256; i++) {
+ char c[1], *p;
+ wchar_t wc[1];
+ int len;
+ c[0] = i;
+ p = c;
+ len = 1;
+ if (1 == charset_to_unicode(&p,&len,wc,1,line_codepage,NULL,L"",0))
+ unitab_line[i] = wc[0];