X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/07b2a9cdcc1dda55516a50708556f1f65c6e9418..f80d4744684828c7b99f1dc25d4b21cf0b59c786:/unicode.c diff --git a/unicode.c b/unicode.c index d1428bb6..2412e406 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}, @@ -443,7 +465,7 @@ void init_ucs(Config *cfg, struct unicode_data *ucsdata) if (ucsdata->dbcs_screenfont || ucsdata->font_codepage == 0) { get_unitab(ucsdata->font_codepage, ucsdata->unitab_font, 2); for (i = 128; i < 256; i++) - ucsdata->unitab_font[i] = (WCHAR) (ATTR_ACP + i); + ucsdata->unitab_font[i] = (WCHAR) (CSET_ACP + i); } else { get_unitab(ucsdata->font_codepage, ucsdata->unitab_font, 1); @@ -475,7 +497,7 @@ void init_ucs(Config *cfg, struct unicode_data *ucsdata) for (i = 0; i < 32; i++) ucsdata->unitab_line[i] = (WCHAR) i; for (i = 32; i < 256; i++) - ucsdata->unitab_line[i] = (WCHAR) (ATTR_ACP + i); + ucsdata->unitab_line[i] = (WCHAR) (CSET_ACP + i); ucsdata->unitab_line[127] = (WCHAR) 127; } else { get_unitab(ucsdata->line_codepage, ucsdata->unitab_line, 0); @@ -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; @@ -539,15 +561,15 @@ void init_ucs(Config *cfg, struct unicode_data *ucsdata) /* Generate line->screen direct conversion links. */ if (cfg->vtmode == VT_OEMANSI || cfg->vtmode == VT_XWINDOWS) - link_font(ucsdata->unitab_scoacs, ucsdata->unitab_oemcp, ATTR_OEMCP); + link_font(ucsdata->unitab_scoacs, ucsdata->unitab_oemcp, CSET_OEMCP); - link_font(ucsdata->unitab_line, ucsdata->unitab_font, ATTR_ACP); - link_font(ucsdata->unitab_scoacs, ucsdata->unitab_font, ATTR_ACP); - link_font(ucsdata->unitab_xterm, ucsdata->unitab_font, ATTR_ACP); + link_font(ucsdata->unitab_line, ucsdata->unitab_font, CSET_ACP); + link_font(ucsdata->unitab_scoacs, ucsdata->unitab_font, CSET_ACP); + link_font(ucsdata->unitab_xterm, ucsdata->unitab_font, CSET_ACP); if (cfg->vtmode == VT_OEMANSI || cfg->vtmode == VT_XWINDOWS) { - link_font(ucsdata->unitab_line, ucsdata->unitab_oemcp, ATTR_OEMCP); - link_font(ucsdata->unitab_xterm, ucsdata->unitab_oemcp, ATTR_OEMCP); + link_font(ucsdata->unitab_line, ucsdata->unitab_oemcp, CSET_OEMCP); + link_font(ucsdata->unitab_xterm, ucsdata->unitab_oemcp, CSET_OEMCP); } if (ucsdata->dbcs_screenfont && @@ -555,7 +577,7 @@ void init_ucs(Config *cfg, struct unicode_data *ucsdata) /* F***ing Microsoft fonts, Japanese and Korean codepage fonts * have a currency symbol at 0x5C but their unicode value is * still given as U+005C not the correct U+00A5. */ - ucsdata->unitab_line['\\'] = ATTR_OEMCP + '\\'; + ucsdata->unitab_line['\\'] = CSET_OEMCP + '\\'; } /* Last chance, if !unicode then try poorman links. */ @@ -571,17 +593,17 @@ void init_ucs(Config *cfg, struct unicode_data *ucsdata) ucsdata->unitab_line[i] >= 160 && ucsdata->unitab_line[i] < 256) { ucsdata->unitab_line[i] = - (WCHAR) (ATTR_ACP + + (WCHAR) (CSET_ACP + poorman_latin1[ucsdata->unitab_line[i] - 160]); } for (i = 96; i < 127; i++) if (!DIRECT_FONT(ucsdata->unitab_xterm[i])) ucsdata->unitab_xterm[i] = - (WCHAR) (ATTR_ACP + poorman_vt100[i - 96]); + (WCHAR) (CSET_ACP + poorman_vt100[i - 96]); for(i=128;i<256;i++) if (!DIRECT_FONT(ucsdata->unitab_scoacs[i])) ucsdata->unitab_scoacs[i] = - (WCHAR) (ATTR_ACP + poorman_scoacs[i - 128]); + (WCHAR) (CSET_ACP + poorman_scoacs[i - 128]); } } @@ -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;