title: Russian (or non-latin) filename load Qt Windows
body: <p>I'm trying to load files on a Qt/C++ software that include non-Latin characters.
  The problem reported by a user with Russian filenames and I tried to quickly fix it with the code below.</p>
  
  <p>Example filename was (I don't read or write russian!): Летний сад.dgr</p>
  
  <pre><code>bool QDepthmapView::loadFile(const QString &amp;fileName)
  {
      m_open_file_name = fileName;
      m_redraw_all = 1;
      // this fixes the problem on a MacOSX but NOT on Windows!
      QByteArray ba = fileName.toUtf8(); 
      char *file = ba.data();
      // end of fix
      if(pDoc-&gt;OnOpenDocument(file)) // quick fix for weird chars (russian filename bug report)
      {
          // removed 
      }
      return false;
  }
  </code></pre>
  
  <p>The above fix was a quick a dirty thing I found online, it works on my MacOSX10.8, but it seems that Windows handles non-ASCII chars a bit differently and I'm not familiar with it.</p>
  
  <p>I'm looking for a multi-platform solution (the software runs on Win, Mac and Linux) for loading non-ASCII filenames.</p>
  
  <p>EDIT regarding comments below:
  <code>OnOpenDocument</code> goes to:</p>
  
  <pre><code>int QGraphDoc::OnOpenDocument(char* lpszPathName) 
  {
  
     m_opened_name = QString(lpszPathName);
  
     int ok = m_meta_graph-&gt;read( lpszPathName );
  // removed //
  
  }
  
  ####
  int read( const pstring&amp; filename )
  {
  // cleared
  
  #ifdef _WIN32
     ifstream stream( filename.c_str(), ios::binary | ios::in );
  #else
     ifstream stream( filename.c_str(), ios::in );
  #endif
  
  //cleared
  
     stream.read( (char *) &amp;version, sizeof( version ) );
  
  // cleared
     }
  ####
  
  template &lt;class T&gt;
  istream&amp; pmemvec&lt;T&gt;::read( istream&amp; stream, streampos offset )
  {
     if (offset != streampos(-1)) {
        stream.seekg( offset );
     }
     // READ / WRITE USES 32-bit LENGTHS (number of elements)
     // n.b., do not change this to size_t as it will cause 32-bit to 64-bit conversion problems
     unsigned int length;
     stream.read( (char *) &amp;length, sizeof(unsigned int) );
     m_length = size_t(length);
     if (m_length &gt;= storage_size()) {
        if (m_data) {
           delete [] m_data;
           m_data = NULL;
        }
        while (m_length &gt;= storage_size())
           m_shift++;
        m_data = new T [storage_size()];
        if (!m_data)
           throw pexception( pexception::MEMORY_ALLOCATION, sizeof(T) * storage_size() );
     }
     if (m_length != 0) {
        stream.read( (char *) m_data, sizeof(T) * streamsize(m_length) );
     }
     return stream;
  }
  </code></pre>