title: Display wchar_t using ncurses
body: <p>i'm currently working on a C++ project in which I need to display some extended characters (wchar_t).</p>
  
  <p>The main problem is that, even if it works fine in C (using <code>wprintf</code>), it doesn't work in c++ using <code>mvwaddwstr</code> or <code>waddwstr</code>. Of course, i've set the locale like that:   <code>setlocale(LC_ALL, "");</code>, and nothing is displayed.</p>
  
  <p>Does someone got this problem before, or has an idea about that?</p>
  
  <p>Thanks.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>  struct charMap { int x; int y; wchar_t value };
    int                   i, x, y;
    wchar_t               str[2];
    struct charMap _charMap[2] = {
      {0,0,9474}
      {29, 29, 9474}
    };
    initscr();
    setlocale(LC_ALL, "");
    for (y = 0 ; y &lt; 30 /* length */ + 2 ; y++) {
      for (x = 0 ; x &lt; 30 /* width */ + 2; x++) {
        for (i = 0 ; i &lt; 2 ; i++) {
          if ((x == _charMap[i].x || _charMap[i].x == -1) &amp;&amp;
              (y == _charMap[i].y || _charMap[i].y == -1)) {
            str[0] = _charMap[i].value;
            str[1] = L'\0';
            mvwaddwstr(stdscr, y, x, str);
            break;
          }
        }
      }
    }
    refresh();
    while(1);
  </code></pre>
  
  <p>_charMap is a struct table containing useful values for easy comparison (avoiding the heavy <code>if ... else if ... else</code> structure). <code>_charMap[].value</code> is a <code>wchar_t</code>, and <code>_charMap[].x</code> is an int, like <code>_charMap[].y</code>.</p>