title: Unable to write a std::wstring into wofstream
body: <p>I'm using Qt/C++ on a Linux system. I need to convert a <code>QLineEdit</code>'s text to <code>std::wstring</code> and write it into a <code>std::wofstream</code>. It works correctly for ascii strings, but when I enter any other character (Arabic or Uzbek) there is nothing written in the file. (size of file is 0 bytes). </p>
  
  <p>this is my code:</p>
  
  <pre><code>wofstream customersFile;
  customersFile.open("./customers.txt");
  std::wstring ws = lne_address_customer-&gt;text().toStdWString();
  customersFile &lt;&lt; ws &lt;&lt; ws.length() &lt;&lt; std::endl;
  </code></pre>
  
  <p>Output for <code>John Smith</code> entered in the line edit is <code>John Smith10</code>. but for unicode strings, nothing.</p>
  
  <p>First I thought that is a problem with <code>QString::toStdWString()</code>, but <code>customersFile &lt;&lt; ws.length();</code> writes correct length of all strings. So I guess I'm doing something wrong wrong with writing <code>wstring</code> in file. [?]</p>
  
  <p>EDIT:</p>
  
  <p>I write it again in eclipse. and compiled it with g++4.5. result is same:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;fstream&gt;
  
  using namespace std;
  
  int main()
  {
     cout &lt;&lt; "" &lt;&lt; endl; // prints
     wstring ws = L"سلام"; // this is an Arabic "Hello"
     wofstream wf("new.txt");
     if (!wf.bad())
        wf &lt;&lt; ws;
     else
        cerr &lt;&lt; "some problem";
     return 0;
  }
  </code></pre>