title: writing unicode characters/string to file
body: <p>I'm trying to write unicode characters to file with <code>std::wofstream</code> but the <code>put</code> or <code>write</code> function doesn't write any characters.</p>
  
  <p>Sample code:</p>
  
  <pre><code>#include &lt;fstream&gt;
  #include &lt;iostream&gt;
  
  int main()
  {
      std::wofstream file;
      file.open("output.txt", std::ios::app);
      if (file.is_open())
      {
          wchar_t test = L'й';
          const wchar_t* str = L"фывдлао";
          file.put(test);
          file.write(str, sizeof(str));
          file.close();
      }
      else
      {
          std::wcerr &lt;&lt; L"Failed to open file" &lt;&lt; std::endl;
      }
  
      std::cin.get();
      return 0;
  }
  </code></pre>
  
  <p><code>output.txt</code> file is empty, no wchar/string is written after executing code, why? what am I doing wrong?</p>
  
  <p><strong>EDIT:</strong>
  Corected code:</p>
  
  <pre><code>#include &lt;fstream&gt;
  #include &lt;iostream&gt;
  
  int main()
  {
      std::wofstream file;
      file.open("output.txt", std::ios::app);
      if (file.is_open())
      {
          wchar_t test = L'й';
          const wchar_t* str = L"фывдлао";
          file.put(test);
          if (!file.good())
          {
              std::wcerr &lt;&lt; L"Failed to write" &lt;&lt; std::endl;
          }
          file.write(str, 8);
          file.close();
      }
      else
      {
          std::wcerr &lt;&lt; L"Failed to open file" &lt;&lt; std::endl;
      }
  
      std::cin.get();
      return 0;
  }
  </code></pre>
  
  <p>After applying code correction I'm presented with <code>Failed to write</code> but I still don't understand what do I need to do to write wide strings and chars?</p>