星期日, 6月 17, 2012

 

讓PuTTY支援UTF-8下使用LineDraw字元


偶爾冒一下泡 XD
Index: terminal.c
===================================================================
--- terminal.c (revision 9566)
+++ terminal.c (working copy)
@@ -2687,9 +2687,46 @@
     case 0:
       if (c < 0x80) {
    /* UTF-8 must be stateless so we ignore iso2022. */
-   if (term->ucsdata->unitab_ctrl[c] != 0xFF) 
+   /*if (term->ucsdata->unitab_ctrl[c] != 0xFF) 
         c = term->ucsdata->unitab_ctrl[c];
-   else c = ((unsigned char)c) | CSET_ASCII;
+   else c = ((unsigned char)c) | CSET_ASCII;*/
+    if(term->sco_acs && 
+        (c!='\033' && c!='\012' && c!='\015' && c!='\b'))
+       {
+          if (term->sco_acs == 2) c |= 0x80;
+          c |= CSET_SCOACS;
+       } else {
+    switch (term->cset_attr[term->cset]) {
+        /* 
+         * Linedraw characters are different from 'ESC ( B'
+         * only for a small range. For ones outside that
+         * range, make sure we use the same font as well as
+         * the same encoding.
+         */
+      case CSET_LINEDRW:
+        if (term->ucsdata->unitab_ctrl[c] != 0xFF)
+     c = term->ucsdata->unitab_ctrl[c];
+        else
+     c = ((unsigned char) c) | CSET_LINEDRW;
+        break;
+
+      case CSET_GBCHR:
+        /* If UK-ASCII, make the '#' a LineDraw Pound */
+        if (c == '#') {
+     c = '}' | CSET_LINEDRW;
+     break;
+        }
+      /*FALLTHROUGH*/ case CSET_ASCII:
+        if (term->ucsdata->unitab_ctrl[c] != 0xFF)
+     c = term->ucsdata->unitab_ctrl[c];
+        else
+     c = ((unsigned char) c) | CSET_ASCII;
+        break;
+    case CSET_SCOACS:
+        if (c>=' ') c = ((unsigned char)c) | CSET_SCOACS;
+        break;
+    }
+       }
    break;
       } else if ((c & 0xe0) == 0xc0) {
    term->utf_size = term->utf_state = 1;

標籤: ,


留言


發佈回應

發佈留言

留不了言?試試在這裡留吧。
回首頁