Add the names of major contributors to the copyright statement. I've
[u/mdw/putty] / unicode.c
index 45ca745..8dfe1d1 100644 (file)
--- a/unicode.c
+++ b/unicode.c
@@ -16,7 +16,7 @@ static void get_unitab(int codepage, wchar_t * unitab, int ftype);
 
 /* Character conversion arrays; they are usually taken from windows,
  * the xterm one has the four scanlines that have no unicode 2.0
- * equlivents mapped into the private area.
+ * equivalents mapped to their unicode 3.0 locations.
  */
 static char **uni_tbl;
 
@@ -63,7 +63,7 @@ static wchar_t iso_8859_11[] = {
     0x0E58, 0x0E59, 0x0E5A, 0x0E5B, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD
 };
 
-static wchar_t iso_8859_12[] = {
+static wchar_t iso_8859_13[] = {
     0x00A0, 0x201D, 0x00A2, 0x00A3, 0x00A4, 0x201E, 0x00A6, 0x00A7,
     0x00D8, 0x00A9, 0x0156, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00C6,
     0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x201C, 0x00B5, 0x00B6, 0x00B7,
@@ -108,6 +108,21 @@ static wchar_t iso_8859_15[] = {
     0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x00ff
 };
 
+static wchar_t iso_8859_16[] = {
+    0x00A0, 0x0104, 0x0105, 0x0141, 0x20AC, 0x201E, 0x0160, 0x00A7,
+    0x0161, 0x00A9, 0x0218, 0x00AB, 0x0179, 0x00AD, 0x017A, 0x017B,
+    0x00B0, 0x00B1, 0x010C, 0x0142, 0x017D, 0x201D, 0x00B6, 0x00B7,
+    0x017E, 0x010D, 0x0219, 0x00BB, 0x0152, 0x0153, 0x0178, 0x017C,
+    0x00C0, 0x00C1, 0x00C2, 0x0102, 0x00C4, 0x0106, 0x00C6, 0x00C7,
+    0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF,
+    0x0110, 0x0143, 0x00D2, 0x00D3, 0x00D4, 0x0150, 0x00D6, 0x015A,
+    0x0170, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x0118, 0x021A, 0x00DF,
+    0x00E0, 0x00E1, 0x00E2, 0x0103, 0x00E4, 0x0107, 0x00E6, 0x00E7,
+    0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
+    0x0111, 0x0144, 0x00F2, 0x00F3, 0x00F4, 0x0151, 0x00F6, 0x015B,
+    0x0171, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x0119, 0x021B, 0x00FF
+};
+
 static wchar_t roman8[] = {
     0x00A0, 0x00C0, 0x00C2, 0x00C8, 0x00CA, 0x00CB, 0x00CE, 0x00CF,
     0x00B4, 0x02CB, 0x02C6, 0x00A8, 0x02DC, 0x00D9, 0x00DB, 0x20A4,
@@ -210,10 +225,11 @@ static struct cp_list_item cp_list[] = {
     {"ISO-8859-8:1988", 28598},
     {"ISO-8859-9:1989", 28599},
     {"ISO-8859-10:1993", 0, 96, iso_8859_10},
-    {"ISO-8859-11", 0, 96, iso_8859_11},
-    {"ISO-8859-12", 0, 96, iso_8859_12},
-    {"ISO-8859-14", 0, 96, iso_8859_14},
+    {"ISO-8859-11:1997", 0, 96, iso_8859_11},
+    {"ISO-8859-13:1998", 0, 96, iso_8859_13},
+    {"ISO-8859-14:1998", 0, 96, iso_8859_14},
     {"ISO-8859-15:1998", 0, 96, iso_8859_15},
+    {"ISO-8859-16:2001", 0, 96, iso_8859_16},
 
     {"UTF-8", CP_UTF8},
 
@@ -251,7 +267,7 @@ void init_ucs_tables(void)
     int i, j;
     int used_dtf = 0;
     char tbuf[256];
-    int old_codepage = line_codepage;
+
     for (i = 0; i < 256; i++)
        tbuf[i] = i;
 
@@ -404,14 +420,14 @@ void init_ucs_tables(void)
 
 static void link_font(WCHAR * line_tbl, WCHAR * font_tbl, WCHAR attr)
 {
-    int i, j, k;
-    for (k = 0; k < 256; k++) {
-       i = ((k + 32) & 0xFF);
-       if (DIRECT_FONT(line_tbl[i]))
+    int font_index, line_index, i;
+    for (line_index = 0; line_index < 256; line_index++) {
+       if (DIRECT_FONT(line_tbl[line_index]))
            continue;
-       for (j = 0; j < 256; j++) {
-           if (line_tbl[i] == font_tbl[j]) {
-               line_tbl[i] = (WCHAR) (attr + j);
+       for(i = 0; i < 256; i++) {
+           font_index = ((32 + i) & 0xFF);
+           if (line_tbl[line_index] == font_tbl[font_index]) {
+               line_tbl[line_index] = (WCHAR) (attr + font_index);
                break;
            }
        }
@@ -458,6 +474,9 @@ void luni_send(wchar_t * widebuf, int len)
        /* UTF is a simple algorithm */
        for (p = linebuffer, i = 0; i < len; i++) {
            wchar_t ch = widebuf[i];
+           /* Windows wchar_t is UTF-16 */
+           if ((ch&0xF800) == 0xD800) ch = '.';
+
            if (ch < 0x80) {
                *p++ = (char) (ch);
            } else if (ch < 0x800) {