title: How can I convert a Unicode path to a c string?
body: <p>How can i convert from a Unicode path name (LPWSTR) to the ASCII equivalent? The library that gets called understands only c strings.</p>
  
  <p>Edit:
  Okay, I took the GetShortPathName and the WideCharToMultiByte suggestions and created that piece of code, i tested it with some folders containing Unicode characters in the path and it worked flawlessly:</p>
  
  <pre><code>wlength = GetShortPathNameW(cpy,0,0);
  LPWSTR shortp = (LPWSTR)calloc(wlength,sizeof(WCHAR));
  GetShortPathNameW(cpy,shortp,wlength);
  clength = WideCharToMultiByte(CP_OEMCP, WC_NO_BEST_FIT_CHARS, shortp, wlength, 0, 0, 0, 0);
  LPSTR cpath = (LPSTR)calloc(clength,sizeof(CHAR));
  WideCharToMultiByte(CP_OEMCP, WC_NO_BEST_FIT_CHARS, shortp, wlength, cpath, clength, 0, 0);
  </code></pre>