title: How to open and read the content of a file with unicode path or filename by using standard API?
body: <p>How to open a file which path or file name contains unicode characters and read or write it's content without using any special API ?. How to do it using only std libraries if it's possible or using only windows API ?. I did try std::wifstream to open a file as in the code sample below, but it doesn't compile. Looks like it doesn't take 'const wchar_t*' argument but 'const char*'. I'm using TDM-GCC 4.7.1 compiler which is included with Dev-C++ IDE.</p>
  
  <pre><code>#ifndef UNICODE
  #define UNICODE
  #endif
  ...
  #include &lt;clocale&gt;
  #include &lt;windows.h&gt;
  #include &lt;fstream&gt;
  ...
  int main(int argc, char **argv)
  {
      setlocale(LC_ALL, "Polish_Poland.852") ;
      ...
      fileCompare(first, second) ;
      ...
  }
  ...
  bool fileCompare(wstring first, wstring second)  // This function doesn't compile !
  {
      using namespace std ;
      wifstream fin0(first.c_str(), ios::binary) ;
      wifstream fin1(second.c_str(), ios::binary) ;
      ...
  }
  </code></pre>
  
  <p>Some complete example:</p>
  
  <pre><code>#ifndef UNICODE
  #define UNICODE
  #endif
  
  #include &lt;clocale&gt;
  #include &lt;conio.h&gt;
  #include &lt;windows.h&gt;
  #include &lt;fstream&gt;
  #include &lt;string&gt;
  #include &lt;iostream&gt;
  
  using namespace std ;
  
  bool fileCompare(wstring first, wstring second) ;
  
  int main(int argc, char **argv)
  {
      setlocale(LC_ALL, "Polish_Poland.852") ;
  
      wstring first, second ;
      first = L"C:\\A.dat" ;
      second = L"C:\\E.dat" ;
  
      fileCompare(first, second) ;
  
      getch() ;
      return 0 ;
  }
  
  bool fileCompare(wstring first, wstring second)  // This function doesn't compile !
  {
      wifstream fin0(first.c_str(), ios::binary) ;
      wifstream fin1(second.c_str(), ios::binary) ;
  
  }
  </code></pre>
  
  <p>Also when I replace L"C:\A.dat" and L"C:\E.dat" to strings containing Polish characters it outputs an error about illegal byte sequence.</p>