title: Graphic problems with the ncurses library in C
body: <p><strong><em>Premise:</em></strong> I'm programming a client-server game in C. The game graphics are built entirely with the support of the ncurses.h library (to be specific <strong>ncursesw</strong>). </p>
  
  <p><strong><em>Problem:</em></strong> The game is programmed in a Linux environment (Ubuntu - 19.04) on a virtual machine on Windows 10. When I start the game in the same programming environment (Linux -> Ubuntu - 19.04), the game graphics works perfectly:</p>
  
  <p>Screenshot: Working graphics Linux (Ubuntu - 19.04) on a virtual machine Win10</p>
  
  <p><img src="https://i.stack.imgur.com/NQ4zC.png" alt="Screenshot: Working graphics Linux (Ubuntu - 19.04) on a virtual machine Win10"></p>
  
  <p>However, in any other environment like WLS (Windows Subsystem for Linux), Linux (Ubuntu 19.04/19.10 <strong>not on virtual machine</strong>) etc.. Graphics are not working properly <em>(One of the stranger things is that sometimes the graphics are initialized correctly)</em>:</p>
  
  <p>Screenshot: Graphics not working properly Linux (Ubuntu - 19.04)</p>
  
  <p><img src="https://i.stack.imgur.com/TxlqB.jpg" alt="Screenshot: Graphics not working properly Linux (Ubuntu - 19.04)"></p>
  
  <p><strong><em>Code:</em></strong> <a href="https://pastebin.com/bcE4vAF1" rel="nofollow noreferrer">full server code here</a> Below the main graphic function:</p>
  
  <pre><code>int initInterface(char* blueprint){
  
      char basicComponent[1];
      int bytesReaded;
      int hudFile;
      pthread_t tidUpdateChat;
      LpMsg msgChat;
      char msg[CHAT_WIDTH];
  
      sleep(1);
  
      /* Verifica la compatibilitÃ  dei colori con il terminale */
      if(!has_colors()){
        endwin();
        printf("\a\n\x1b[31m &lt;!&gt; Il tuo terminale non supporta i colori.\n\n\x1b[0m");
        return 1;
      }
      start_color();
  
      /* Inizializzazione della grafica */
      if((hudFile = open(blueprint, O_RDONLY)) == -1){
        endwin();
        printf("\a\n\x1b[31m &lt;!&gt; Errore durante l'inizializzazione dell'interfaccia grafica.\n\n\x1b[0m");
        return 1;
      }
      while((bytesReaded = read(hudFile, basicComponent, 1)) &gt; 0){
        if(bytesReaded == -1){
          endwin();
          printf("\a\n\x1b[31m &lt;!&gt; Errore durante l'inizializzazione dell'interfaccia grafica.\n\n\x1b[0m");
          return 1;
        }
        basicComponent[bytesReaded] = '\0';
        basicComponent[0] = initStructures(basicComponent[0]);
        if(basicComponent[0] == FIELD_BLUEPRINT){
          printw(" ");
        } else{
          printw("%s", basicComponent);
        }
      }
      close(hudFile);
  
      /* Disabilito la ristampa dei caratteri catturati da getch */
      noecho();
  
      /* Rendo il cursore invisibile */
      curs_set(0);
  
      /* Definizione dei vari design */
      init_color(COLOR_BLACK, 784, 803, 694);
      init_color(COLOR_WHITE, 8, 0, 60);
  
      init_pair(DESIGN_THEME, COLOR_BLACK, COLOR_WHITE);
      init_pair(DESIGN_RED, COLOR_RED, COLOR_WHITE);
      init_pair(DESIGN_CYAN, COLOR_CYAN, COLOR_WHITE);
      init_pair(DESIGN_YELLOW, COLOR_YELLOW, COLOR_WHITE);
      init_pair(DESIGN_GREEN, COLOR_GREEN, COLOR_WHITE);
      init_pair(DESIGN_BLUE, COLOR_BLUE, COLOR_WHITE);
  
      init_pair(DESIGN_GRASS, COLOR_GREEN, COLOR_GREEN);
      init_pair(DESIGN_BRICK, COLOR_BLUE, COLOR_WHITE);
      init_pair(DESIGN_PACKET, COLOR_RED, COLOR_GREEN);
      init_pair(DESIGN_LOCATION, COLOR_BLACK, COLOR_MAGENTA);
      init_pair(DESIGN_PLAYER, COLOR_BLUE, COLOR_GREEN);
  
      /* Cambio il colore dello sfondo e del testo */
      bkgd(COLOR_PAIR(DESIGN_THEME));
  
      sprintf(msg, "Sono in ascolto sulla porta %d!", listenerPort);
      if((msgChat = allocMsg(msg, DESIGN_BLUE, false)) != NULL){
        pthread_create(&amp;tidUpdateChat, NULL, updateChat, msgChat);
      }
  
      /* Commit della grafica */
      refresh();
  
      return 0;
  }
  </code></pre>
  
  <p><strong><em>Some information:</em></strong></p>
  
  <ul>
  <li>In main i initialize the locale and the ncurses window.</li>
  <li>The graphics are initialized from of a file, in practice I am going to read character by character from the file. Here the file: <a href="https://pastebin.com/uca9UGda" rel="nofollow noreferrer">graphics.txt</a></li>
  </ul>
  
  <p>What could be the problem? Could it be a character encoding error? If more information is needed, please ask. Thank to all.</p>