X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/c85623f918b8a6c639afc15604414f9b113bb20d..f33ba69e92f389f5884eae5a586858a629a5260b:/unicode.c diff --git a/unicode.c b/unicode.c index 24dfd448..c3c052a4 100644 --- a/unicode.c +++ b/unicode.c @@ -1,7 +1,3 @@ -#ifdef WINDOWS -#include -#endif - #include #include #include @@ -361,6 +357,31 @@ static const wchar_t dec_mcs[] = { 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FF, 0xFFFD, 0xFFFD }; +/* Mazovia (Polish) aka CP620 + * from "Mazowia to Unicode table", 04/24/96, Mikolaj Jedrzejak */ +static const wchar_t mazovia[] = { + /* Code point 0x9B is "zloty" symbol (zŽ), which is not + * widely used and for which there is no Unicode equivalent. + * One reference shows 0xA8 as U+00A7 SECTION SIGN, but we're + * told that's incorrect. */ + 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x0105, 0x00E7, + 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x0107, 0x00C4, 0x0104, + 0x0118, 0x0119, 0x0142, 0x00F4, 0x00F6, 0x0106, 0x00FB, 0x00F9, + 0x015a, 0x00D6, 0x00DC, 0xFFFD, 0x0141, 0x00A5, 0x015b, 0x0192, + 0x0179, 0x017b, 0x00F3, 0x00d3, 0x0144, 0x0143, 0x017a, 0x017c, + 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, + 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, + 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, + 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, + 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, + 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, + 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, + 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, + 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, + 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, + 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 +}; + struct cp_list_item { char *name; int codepage; @@ -404,6 +425,7 @@ static const struct cp_list_item cp_list[] = { {"Win1258 (Vietnamese)", 1258}, {"CP437", 437}, + {"CP620 (Mazovia)", 0, 128, mazovia}, {"CP819", 28591}, {"CP878", 20866}, @@ -516,12 +538,12 @@ void init_ucs(Config *cfg, struct unicode_data *ucsdata) if (DIRECT_FONT(ucsdata->unitab_line[i])) continue; if (!ucsdata->uni_tbl) { - ucsdata->uni_tbl = smalloc(256 * sizeof(char *)); + ucsdata->uni_tbl = snewn(256, char *); memset(ucsdata->uni_tbl, 0, 256 * sizeof(char *)); } j = ((ucsdata->unitab_line[i] >> 8) & 0xFF); if (!ucsdata->uni_tbl[j]) { - ucsdata->uni_tbl[j] = smalloc(256 * sizeof(char)); + ucsdata->uni_tbl[j] = snewn(256, char); memset(ucsdata->uni_tbl[j], 0, 256 * sizeof(char)); } ucsdata->uni_tbl[j][ucsdata->unitab_line[i] & 0xFF] = i; @@ -971,9 +993,9 @@ int check_compose_internal(int first, int second, int recurse) if (recurse == 0) { nc = check_compose_internal(second, first, 1); if (nc == -1) - nc = check_compose(toupper(first), toupper(second), 1); + nc = check_compose_internal(toupper(first), toupper(second), 1); if (nc == -1) - nc = check_compose(toupper(second), toupper(first), 1); + nc = check_compose_internal(toupper(second), toupper(first), 1); } return nc; } @@ -1015,7 +1037,7 @@ int decode_codepage(char *cp_name) * 1254 -> ISO 8859-9 * 1255 -> ISO 8859-8 * 1256 -> ISO 8859-6 - * 1257 -> ISO 8859-4 + * 1257 -> ISO 8859-13 (changed from 8859-4 on advice of a Lithuanian) * * and for anything else, choose direct-to-font. */ @@ -1028,7 +1050,7 @@ int decode_codepage(char *cp_name) 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; + case 1257: cp_name = "ISO-8859-13"; break; /* default: leave it blank, which will select -1, direct->font */ } } @@ -1094,7 +1116,7 @@ int decode_codepage(char *cp_name) return codepage; } -char *cp_name(int codepage) +const char *cp_name(int codepage) { const struct cp_list_item *cpi, *cpno; static char buf[32]; @@ -1134,7 +1156,7 @@ char *cp_name(int codepage) * 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;