mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-03-22 14:39:24 -05:00
Unicode cleanup phase 2: we now reintroduce the ability to enter a
numeric code page, and also reinstate the direct-to-font zero translation mode (but now under an actual _name_ rather than blank). Also add CP437 to the list since at least one expatriate DOS user wanted it; also select a sensible ISO or KOI codepage based on the system locale. [originally from svn r1230]
This commit is contained in:
parent
6dacf35120
commit
12e7195c0e
@ -457,7 +457,11 @@ void load_settings(char *section, int do_host, Config * cfg)
|
|||||||
cfg->wordness[j] = atoi(q);
|
cfg->wordness[j] = atoi(q);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gpps(sesskey, "LineCodePage", "ISO-8859-1:1987", cfg->line_codepage,
|
/*
|
||||||
|
* The empty default for LineCodePage will be converted later
|
||||||
|
* into a plausible default for the locale.
|
||||||
|
*/
|
||||||
|
gpps(sesskey, "LineCodePage", "", cfg->line_codepage,
|
||||||
sizeof(cfg->line_codepage));
|
sizeof(cfg->line_codepage));
|
||||||
gppi(sesskey, "ScrollBar", 1, &cfg->scrollbar);
|
gppi(sesskey, "ScrollBar", 1, &cfg->scrollbar);
|
||||||
gppi(sesskey, "ScrollOnKey", 0, &cfg->scroll_on_key);
|
gppi(sesskey, "ScrollOnKey", 0, &cfg->scroll_on_key);
|
||||||
|
81
unicode.c
81
unicode.c
@ -233,36 +233,14 @@ static struct cp_list_item cp_list[] = {
|
|||||||
{"Win1257 (Baltic)", 1257},
|
{"Win1257 (Baltic)", 1257},
|
||||||
{"Win1258 (Vietnamese)", 1258},
|
{"Win1258 (Vietnamese)", 1258},
|
||||||
|
|
||||||
/* All below here are aliases - First the windows ones. */
|
{"Win1258 (Vietnamese)", 1258},
|
||||||
{"Central European (Win1250)", 1250},
|
|
||||||
{"Cyrillic (Win1251)", 1251},
|
|
||||||
{"Western (Win1252)", 1252},
|
|
||||||
{"Greek (Win1253)", 1253},
|
|
||||||
{"Turkish (Win1254)", 1254},
|
|
||||||
{"Hebrew (Win1255)", 1255},
|
|
||||||
{"Arabic (Win1256)", 1256},
|
|
||||||
{"Baltic (Win1257)", 1257},
|
|
||||||
{"Vietnamese (Win1258)", 1258},
|
|
||||||
|
|
||||||
{"ROMAN8", 0, 96, roman8},
|
|
||||||
{"R8", 0, 96, roman8},
|
|
||||||
|
|
||||||
/* Note this is Latin ->> */
|
|
||||||
{"LATIN0", 0, 96, iso_8859_15},
|
|
||||||
{"L0", 0, 96, iso_8859_15},
|
|
||||||
|
|
||||||
|
{"CP437", 437},
|
||||||
{"CP819", 28591},
|
{"CP819", 28591},
|
||||||
{"CP878", 20866},
|
{"CP878", 20866},
|
||||||
{"L1", 28591},
|
|
||||||
{"L2", 28592},
|
{"Use font encoding", -1},
|
||||||
{"L3", 28593},
|
|
||||||
{"L4", 28594},
|
|
||||||
{"L5", 28599},
|
|
||||||
{"LATIN1", 28591},
|
|
||||||
{"LATIN2", 28592},
|
|
||||||
{"LATIN3", 28593},
|
|
||||||
{"LATIN4", 28594},
|
|
||||||
{"LATIN5", 28599},
|
|
||||||
{0, 0}
|
{0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -884,6 +862,49 @@ int decode_codepage(char *cp_name)
|
|||||||
int codepage = -1;
|
int codepage = -1;
|
||||||
CPINFO cpinfo;
|
CPINFO cpinfo;
|
||||||
|
|
||||||
|
if (!*cp_name) {
|
||||||
|
/*
|
||||||
|
* Here we select a plausible default code page based on
|
||||||
|
* the locale the user is in. We wish to select an ISO code
|
||||||
|
* page or appropriate local default _rather_ than go with
|
||||||
|
* the Win125* series, because it's more important to have
|
||||||
|
* CSI and friends enabled by default than the ghastly
|
||||||
|
* Windows extra quote characters, and because it's more
|
||||||
|
* likely the user is connecting to a remote server that
|
||||||
|
* does something Unixy or VMSy and hence standards-
|
||||||
|
* compliant than that they're connecting back to a Windows
|
||||||
|
* box using horrible nonstandard charsets.
|
||||||
|
*
|
||||||
|
* Accordingly, Robert de Bath suggests a method for
|
||||||
|
* picking a default character set that runs as follows:
|
||||||
|
* first call GetACP to get the system's ANSI code page
|
||||||
|
* identifier, and translate as follows:
|
||||||
|
*
|
||||||
|
* 1250 -> ISO 8859-2
|
||||||
|
* 1251 -> KOI8-U
|
||||||
|
* 1252 -> ISO 8859-1
|
||||||
|
* 1253 -> ISO 8859-7
|
||||||
|
* 1254 -> ISO 8859-9
|
||||||
|
* 1255 -> ISO 8859-8
|
||||||
|
* 1256 -> ISO 8859-6
|
||||||
|
* 1257 -> ISO 8859-4
|
||||||
|
*
|
||||||
|
* and for anything else, choose direct-to-font.
|
||||||
|
*/
|
||||||
|
int cp = GetACP();
|
||||||
|
switch (cp) {
|
||||||
|
case 1250: cp_name = "ISO-8859-2"; break;
|
||||||
|
case 1251: cp_name = "KOI8-U"; break;
|
||||||
|
case 1252: cp_name = "ISO-8859-1"; break;
|
||||||
|
case 1253: cp_name = "ISO-8859-7"; break;
|
||||||
|
case 1254: cp_name = "ISO-8859-9"; break;
|
||||||
|
case 1255: cp_name = "ISO-8859-8"; break;
|
||||||
|
case 1256: cp_name = "ISO-8859-6"; break;
|
||||||
|
case 1257: cp_name = "ISO-8859-4"; break;
|
||||||
|
/* default: leave it blank, which will select -1, direct->font */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (cp_name && *cp_name)
|
if (cp_name && *cp_name)
|
||||||
for (cpi = cp_list; cpi->name; cpi++) {
|
for (cpi = cp_list; cpi->name; cpi++) {
|
||||||
s = cp_name;
|
s = cp_name;
|
||||||
@ -947,6 +968,12 @@ char *cp_name(int codepage)
|
|||||||
{
|
{
|
||||||
struct cp_list_item *cpi, *cpno;
|
struct cp_list_item *cpi, *cpno;
|
||||||
static char buf[32];
|
static char buf[32];
|
||||||
|
|
||||||
|
if (codepage == -1) {
|
||||||
|
sprintf(buf, "Use font encoding");
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
if (codepage > 0 && codepage < 65536)
|
if (codepage > 0 && codepage < 65536)
|
||||||
sprintf(buf, "CP%03d", codepage);
|
sprintf(buf, "CP%03d", codepage);
|
||||||
else
|
else
|
||||||
|
@ -153,10 +153,9 @@ void multiedit(struct ctlpos *cp, ...)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A static line, followed by a full-width drop-down list (ie a
|
* A static line, followed by a full-width combo box.
|
||||||
* non-editing combo box).
|
|
||||||
*/
|
*/
|
||||||
void dropdownlist(struct ctlpos *cp, char *text, int staticid, int listid)
|
void combobox(struct ctlpos *cp, char *text, int staticid, int listid)
|
||||||
{
|
{
|
||||||
RECT r;
|
RECT r;
|
||||||
|
|
||||||
@ -170,7 +169,7 @@ void dropdownlist(struct ctlpos *cp, char *text, int staticid, int listid)
|
|||||||
r.bottom = COMBOHEIGHT * 10;
|
r.bottom = COMBOHEIGHT * 10;
|
||||||
doctl(cp, r, "COMBOBOX",
|
doctl(cp, r, "COMBOBOX",
|
||||||
WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_VSCROLL |
|
WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_VSCROLL |
|
||||||
CBS_DROPDOWNLIST | CBS_HASSTRINGS, WS_EX_CLIENTEDGE, "", listid);
|
CBS_DROPDOWN | CBS_HASSTRINGS, WS_EX_CLIENTEDGE, "", listid);
|
||||||
|
|
||||||
cp->ypos += STATICHEIGHT + GAPWITHIN + COMBOHEIGHT + GAPBETWEEN;
|
cp->ypos += STATICHEIGHT + GAPWITHIN + COMBOHEIGHT + GAPBETWEEN;
|
||||||
}
|
}
|
||||||
|
18
windlg.c
18
windlg.c
@ -784,15 +784,13 @@ static void init_dlg_ctrls(HWND hwnd, int keepsess)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char *cp;
|
char *cp;
|
||||||
int index = 0;
|
strcpy(cfg.line_codepage, cp_name(decode_codepage(cfg.line_codepage)));
|
||||||
SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_RESETCONTENT, 0, 0);
|
SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_RESETCONTENT, 0, 0);
|
||||||
for (i = 0; (cp = cp_enumerate(i)) != NULL; i++) {
|
for (i = 0; (cp = cp_enumerate(i)) != NULL; i++) {
|
||||||
SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_ADDSTRING,
|
SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_ADDSTRING,
|
||||||
0, (LPARAM) cp);
|
0, (LPARAM) cp);
|
||||||
if (!strcmp(cp, cfg.line_codepage))
|
|
||||||
index = i;
|
|
||||||
}
|
}
|
||||||
SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_SETCURSEL, index, 0);
|
SetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage);
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckRadioButton(hwnd, IDC_VTXWINDOWS, IDC_VTUNICODE,
|
CheckRadioButton(hwnd, IDC_VTXWINDOWS, IDC_VTUNICODE,
|
||||||
@ -1104,9 +1102,8 @@ static void create_controls(HWND hwnd, int dlgtype, int panel)
|
|||||||
endbox(&cp);
|
endbox(&cp);
|
||||||
beginbox(&cp, "Character set translation on received data",
|
beginbox(&cp, "Character set translation on received data",
|
||||||
IDC_BOX_TRANSLATION2);
|
IDC_BOX_TRANSLATION2);
|
||||||
dropdownlist(&cp,
|
combobox(&cp, "Received data assumed to be in which character set:",
|
||||||
"Received data assumed to be in which character set:",
|
IDC_CODEPAGESTATIC, IDC_CODEPAGE);
|
||||||
IDC_CODEPAGESTATIC, IDC_CODEPAGE);
|
|
||||||
endbox(&cp);
|
endbox(&cp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2458,6 +2455,13 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg,
|
|||||||
CB_GETCURSEL, 0, 0);
|
CB_GETCURSEL, 0, 0);
|
||||||
SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_GETLBTEXT,
|
SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_GETLBTEXT,
|
||||||
index, (LPARAM)cfg.line_codepage);
|
index, (LPARAM)cfg.line_codepage);
|
||||||
|
} else if (HIWORD(wParam) == CBN_EDITCHANGE) {
|
||||||
|
GetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage,
|
||||||
|
sizeof(cfg.line_codepage) - 1);
|
||||||
|
} else if (HIWORD(wParam) == CBN_KILLFOCUS) {
|
||||||
|
strcpy(cfg.line_codepage,
|
||||||
|
cp_name(decode_codepage(cfg.line_codepage)));
|
||||||
|
SetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IDC_VTXWINDOWS:
|
case IDC_VTXWINDOWS:
|
||||||
|
@ -59,7 +59,7 @@ void static2btn(struct ctlpos *cp, char *stext, int sid,
|
|||||||
char *btext1, int bid1, char *btext2, int bid2);
|
char *btext1, int bid1, char *btext2, int bid2);
|
||||||
void staticedit(struct ctlpos *cp, char *stext,
|
void staticedit(struct ctlpos *cp, char *stext,
|
||||||
int sid, int eid, int percentedit);
|
int sid, int eid, int percentedit);
|
||||||
void dropdownlist(struct ctlpos *cp, char *text, int staticid, int listid);
|
void combobox(struct ctlpos *cp, char *text, int staticid, int listid);
|
||||||
void staticpassedit(struct ctlpos *cp, char *stext,
|
void staticpassedit(struct ctlpos *cp, char *stext,
|
||||||
int sid, int eid, int percentedit);
|
int sid, int eid, int percentedit);
|
||||||
void bigeditctrl(struct ctlpos *cp, char *stext,
|
void bigeditctrl(struct ctlpos *cp, char *stext,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user