+ macmisc macabout
# Character set library, for use in pterm.
-CHARSET = sbcsdat slookup sbcs utf8 toucs fromucs xenc mimeenc macenc
+CHARSET = sbcsdat slookup sbcs utf8 toucs fromucs xenc mimeenc macenc localenc
# Standard libraries, and the same with WinSocks 1 and 2.
LIBS = advapi32.lib user32.lib gdi32.lib comctl32.lib comdlg32.lib
int charset_from_mimeenc(const char *name);
/*
+ * Convert our own encoding names to and from our charset
+ * identifiers.
+ */
+const char *charset_to_localenc(int charset);
+int charset_from_localenc(const char *name);
+int charset_localenc_nth(int n);
+
+/*
* Convert Mac OS script/region/font to our charset identifiers.
*/
int charset_from_macenc(int script, int region, int sysvers,
Config *cfg = (Config *)data;
if (event == EVENT_REFRESH) {
int i;
- char *cp;
+ const char *cp;
dlg_update_start(ctrl, dlg);
strcpy(cfg->line_codepage,
cp_name(decode_codepage(cfg->line_codepage)));
wchar_t xlat_uskbd2cyrllic(int ch);
int check_compose(int first, int second);
int decode_codepage(char *cp_name);
-char *cp_enumerate (int index);
-char *cp_name(int codepage);
+const char *cp_enumerate (int index);
+const char *cp_name(int codepage);
void get_unitab(int codepage, wchar_t * unitab, int ftype);
/*
return codepage;
}
-char *cp_name(int codepage)
+const char *cp_name(int codepage)
{
const struct cp_list_item *cpi, *cpno;
static char buf[32];
* Return the nth code page in the list, for use in the GUI
* configurer.
*/
-char *cp_enumerate(int index)
+const char *cp_enumerate(int index)
{
if (index < 0 || index >= lenof(cp_list))
return NULL;
const char *const appname = "pterm";
-/*
- * Another bunch of temporary stub functions. These ones will want
- * removing by means of implementing them properly: libcharset
- * should invent its own sensible format for codepage names and a
- * means of enumerating them, and printer_enum needs to be dealt
- * with somehow or other too.
- */
-
-char *cp_name(int codepage)
-{
- return "";
-}
-char *cp_enumerate(int index)
-{
- return NULL;
-}
-int decode_codepage(char *cp_name)
-{
- return -2;
-}
-
Backend *select_backend(Config *cfg)
{
return &pty_backend;
/*
* TODO:
*
- * - libcharset enumeration.
- *
- * - fix the printer enum (I think the sensible thing is simply to
- * have uxcfg.c remove the drop-down list completely, since you
- * can't sensibly provide an enumerated list of lpr commands!).
- *
* - Remainder of the context menu:
*
* - Event Log (this means we must implement the Event Log; not
exit(code);
}
-/*
- * Another bunch of temporary stub functions. These ones will want
- * removing by means of implementing them properly: libcharset
- * should invent its own sensible format for codepage names and a
- * means of enumerating them, and printer_enum needs to be dealt
- * with somehow or other too.
- */
-
-char *cp_name(int codepage)
-{
- return "";
-}
-char *cp_enumerate(int index)
-{
- return NULL;
-}
-int decode_codepage(char *cp_name)
-{
- return -2;
-}
-
const char *const appname = "PuTTY";
Backend *select_backend(Config *cfg)
#include <time.h>
#include "putty.h"
+#include "charset.h"
#include "terminal.h"
#include "misc.h"
* line_codepage should be decoded from the specification in
* cfg.
*/
- ucsdata->line_codepage = charset_from_mimeenc(linecharset);
- if (ucsdata->line_codepage == CS_NONE)
- ucsdata->line_codepage = charset_from_xenc(linecharset);
+ ucsdata->line_codepage = decode_codepage(linecharset);
/*
* If line_codepage is _still_ CS_NONE, we assume we're using
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);
+}