title: Proper way to fprintf unicode characters
body: <p>Here is my simple C/C++ program:</p>
  
  <pre><code>int main() {
    FILE* f = fopen("MyTest.log", "w");
  
    fprintf(f, "%ls\n", L"abc");
    fprintf(f, "%ls\n", L"您好"); // Data from a different locale
    fprintf(f, "%ls\n", L"def");
    fclose(f);
  
    return 0;
  }
  </code></pre>
  
  <p>When I run this program, the generated file does not contain the middle line at all. It appears <code>fprintf</code> simply returns back once it detects a different character set in the passed parameter.</p>
  
  <p>I have tested this program on Windows as well as Ubuntu. The same problem at both the places.</p>
  
  <p>Browsing the forum, I found a few hints such as using _setmode() and fwprintf. However, if possible, I would like to stick to fprintf(). Also, my code needs to work on Windows as well as Linux. </p>
  
  <p>Does anyone know to achieve this? Regards.</p>