title: writing a wrapper for fwprintf
body: <p>I'm trying to write a wrapper for <code>fwprintf</code>. I'm using a <code>wstringstream</code> to capture a formatted <code>va_list</code> and then use the actual <code>fwprintf</code> to print to file. For some reason, instead of a nice unicode string, I am getting garbled numbers.</p>
  
  <p>Can anyone help?</p>
  
  <pre><code>void WriteToLog(wchar_t *message, ...)
  {
  FILE * pFile;
  
  if (_wfopen_s (&amp;pFile, SZ_LOG_FILE_PATH,L"a") != 0)
  {
      display_error_message(-1, L"Could not open log file.", IsSilent, MB_ICONSTOP);
      return;
  }
  
  std::wstringstream buffer;
  va_list args;
  va_start(args, message);
  buffer &lt;&lt; vwprintf(message, args);
  va_end(args);
  
  fwprintf(pFile, buffer.str().c_str());
  
  fclose(pFile);
  }
  </code></pre>