+
+ /*
+ * Set up unitab_scoacs. The SCO Alternate Character Set is
+ * simply CP437.
+ */
+ 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, CS_CP437, NULL, L"", 0))
+ ucsdata->unitab_scoacs[i] = wc[0];
+ else
+ ucsdata->unitab_scoacs[i] = 0xFFFD;
+ }
+
+ /*
+ * Find the control characters in the line codepage. For
+ * direct-to-font mode using the D800 hack, we assume 00-1F and
+ * 7F are controls, but allow 80-9F through. (It's as good a
+ * guess as anything; and my bet is that half the weird fonts
+ * used in this way will be IBM or MS code pages anyway.)
+ */
+ for (i = 0; i < 256; i++) {
+ int lineval = ucsdata->unitab_line[i];
+ if (lineval < ' ' || (lineval >= 0x7F && lineval < 0xA0) ||
+ (lineval >= 0xD800 && lineval < 0xD820) || (lineval == 0xD87F))
+ ucsdata->unitab_ctrl[i] = i;
+ else
+ ucsdata->unitab_ctrl[i] = 0xFF;
+ }
+
+ return ret;
+}
+
+const char *cp_name(int codepage)
+{
+ if (codepage == CS_NONE)
+ return "Use font encoding";
+ return charset_to_localenc(codepage);
+}
+
+const char *cp_enumerate(int index)
+{
+ int charset;
+ if (index == 0)
+ return "Use font encoding";
+ charset = charset_localenc_nth(index-1);
+ if (charset == CS_NONE)
+ return NULL;
+ return charset_to_localenc(charset);
+}
+
+int decode_codepage(char *cp_name)
+{
+ if (!*cp_name)
+ return CS_NONE; /* use font encoding */
+ return charset_from_localenc(cp_name);
+}