windows: force codepage to 65001 to show superscript characters 43/21143/5
Antoine ELIAS [Thu, 28 Nov 2019 23:35:17 +0000 (00:35 +0100)]
Change-Id: I6243bd5c7631f227929489404623d5f04d37872a

scilab/modules/core/src/cpp/InitScilab.cpp
scilab/modules/windows_tools/src/c/TerminateWindows_tools.c
scilab/modules/windows_tools/src/c/scilab_windows/console.c
scilab/modules/windows_tools/src/c/scilab_windows/console.h
scilab/modules/windows_tools/src/c/scilab_windows_Import.def

index ee8001b..d3cfae7 100644 (file)
@@ -237,6 +237,8 @@ int StartScilabEngine(ScilabEngineInfo* _pSEI)
         if (scilabMode == SCILAB_NW || scilabMode == SCILAB_NWNI)
         {
             SaveConsoleColors();
+            SaveConsoleFont();
+            UpdateConsoleFont();
             if (scilabMode == SCILAB_NW)
             {
                 RenameConsole();
index 0b6dff1..c26a53d 100644 (file)
@@ -33,8 +33,8 @@ BOOL TerminateWindows_tools(void)
             //CloseScilabConsole();
             closeInnosetupMutex();
             bOK = TRUE;
+            break;
         }
-        break;
 
         case SCILAB_NW:
         {
@@ -42,7 +42,14 @@ BOOL TerminateWindows_tools(void)
             RestoreExitButton();
             bOK = TRUE;
         }
-        break;
+        //continue
+
+        case SCILAB_NWNI: 
+        {
+            RestoreConsoleFont();
+            break;
+        }
+
 
         default:
             break;
index c3a72f9..5ec9494 100644 (file)
@@ -30,6 +30,7 @@
 #define NameConsole "Console"
 /*--------------------------------------------------------------------------*/
 static CONSOLE_SCREEN_BUFFER_INFO csbiInfoSave;
+static UINT savedCodePage;
 static char ScilexConsoleName[MAX_PATH];
 /*--------------------------------------------------------------------------*/
 void UpdateConsoleColors(void)
@@ -41,11 +42,11 @@ void UpdateConsoleColors(void)
     Coord.X = 0;
     Coord.Y = 0;
 
-    FillConsoleOutputAttribute( hConsole,
-                                BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY,
-                                csbiInfoSave.dwSize.X * csbiInfoSave.dwSize.Y,
-                                Coord,
-                                &cWritten);
+    FillConsoleOutputAttribute(hConsole,
+        BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY,
+        csbiInfoSave.dwSize.X * csbiInfoSave.dwSize.Y,
+        Coord,
+        &cWritten);
 
     SetConsoleTextAttribute(hConsole, BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY);
 
@@ -65,14 +66,30 @@ void RestoreConsoleColors(void)
     Coord.X = 0;
     Coord.Y = 0;
 
-    FillConsoleOutputAttribute( hConsole,
-                                csbiInfoSave.wAttributes,
-                                csbiInfoSave.dwSize.X * csbiInfoSave.dwSize.Y,
-                                Coord,
-                                &cWritten);
+    FillConsoleOutputAttribute(hConsole,
+        csbiInfoSave.wAttributes,
+        csbiInfoSave.dwSize.X * csbiInfoSave.dwSize.Y,
+        Coord,
+        &cWritten);
     SetConsoleTextAttribute(hConsole, csbiInfoSave.wAttributes);
 }
 /*--------------------------------------------------------------------------*/
+void UpdateConsoleFont(void)
+{
+    //change codepage to cp65001
+    SetConsoleOutputCP(65001);
+}
+/*--------------------------------------------------------------------------*/
+void SaveConsoleFont(void)
+{
+    savedCodePage = GetConsoleCP();
+}
+/*--------------------------------------------------------------------------*/
+void RestoreConsoleFont(void)
+{
+    SetConsoleCP(savedCodePage);
+}
+/*--------------------------------------------------------------------------*/
 void RenameConsole(void)
 {
     HWND hScilex = NULL;
index 188c38c..a2e0a34 100644 (file)
@@ -35,6 +35,21 @@ SCILAB_WINDOWS_IMPEXP void SaveConsoleColors(void);
 SCILAB_WINDOWS_IMPEXP void RestoreConsoleColors(void);
 
 /**
+* Update font of console
+*/
+SCILAB_WINDOWS_IMPEXP void UpdateConsoleFont(void);
+
+/**
+* Save v before  creation
+*/
+SCILAB_WINDOWS_IMPEXP void SaveConsoleFont(void);
+
+/**
+* Restore font of console
+*/
+SCILAB_WINDOWS_IMPEXP void RestoreConsoleFont(void);
+
+/**
 * Restore Exit button
 */
 SCILAB_WINDOWS_IMPEXP void RestoreExitButton(void);
index 27923fd..55f024a 100644 (file)
@@ -7,6 +7,7 @@ EXPORTS
 ; --------------------------------------- 
 getScilexConsoleName
 RestoreConsoleColors
+RestoreConsoleFont
 closeInnosetupMutex
 RestoreExitButton
 ClosePipeInfo