OSDN Git Service

use wide char for console output
authorSHIRAKATA Kentaro <argrath@ub32.org>
Fri, 27 Aug 2021 10:27:58 +0000 (19:27 +0900)
committerSHIRAKATA Kentaro <argrath@ub32.org>
Sat, 9 Oct 2021 20:28:03 +0000 (05:28 +0900)
sys/winnt/nttty.c

index 602b14b..5ebdef4 100644 (file)
@@ -250,10 +250,9 @@ static void back_buffer_flip()
                 /* pos.x == 0 \82Ì\8fð\8c\8f\82Í\95s\97v\82Ì\82Í\82¸\82¾\82ª #42072 \91Î\8dô\82Å\92Ç\89Á\81B */
                 if (back->character != front->character ||
                     back2->character != front2->character || pos.X == 0) {
-                    unsigned char buf[2];
-                    buf[0] = (unsigned char)(back->character);
-                    buf[1] = (unsigned char)(back2->character);
-                    WriteConsoleOutputCharacter(console.hConOut, buf, 2, pos,
+                    wchar_t wbuf[1];
+                    wbuf[0] = back->character;
+                    WriteConsoleOutputCharacterW(console.hConOut, wbuf, 1, pos,
                                                     &unused);
                     *front = *back;
                     *front2 = *back2;
@@ -627,6 +626,8 @@ unsigned int ch2;
 
     boolean inverse = FALSE;
     cell_t cell;
+    unsigned char buf[2];
+    wchar_t wbuf[1];
 
     /* xputc_core()\82©\82ç\82Ì\83R\83s\81[ */
     inverse = (console.current_nhattr[ATR_INVERSE] && iflags.wc_inverse);
@@ -656,12 +657,24 @@ unsigned int ch2;
         }
     }
 
-    cell.character = ch1;
+    buf[0] = (unsigned char)(ch1);
+    buf[1] = (unsigned char)(ch2);
+    int ret = MultiByteToWideChar(
+        CP_ACP,
+        MB_PRECOMPOSED,
+        buf,
+        2,
+        wbuf,
+        1);
+
+    /* \8d\91¤\82É\83\8f\83C\83h\95\8e\9a\8fî\95ñ\82ð\8bl\82ß\82é */
+    cell.character = wbuf[0];
     cell.iskanji = 1;
     buffer_write(console.back_buffer, &cell, console.cursor);
     console.cursor.X++;
 
-    cell.character = ch2;
+    /* \89E\91¤\82Í\83_\83~\81[ */
+    cell.character = 255;
     cell.iskanji = 2;
     buffer_write(console.back_buffer, &cell, console.cursor);