title: Get directory separator char on Windows? ('\', '/', etc.)
body: <p>tl;dr: How do I ask Windows what the current directory separator character on the system is?</p>
  <hr />
  <p>Different versions of Windows seem to behave differently (e.g. <code>\</code> and <code>/</code> both work on the English versions, <a href="http://blogs.msdn.com/b/oldnewthing/archive/2005/10/14/481044.aspx" rel="noreferrer">¥ is apparently on the Japanese version, ₩ is apparently on the Korean version</a>, etc...</p>
  <p>Is there any way to avoid hard-coding this, and instead ask Windows at run time?</p>
  <h3>Note:</h3>
  <p>Ideally, the solution should <em><strong>not</strong></em> depend on a high-level DLL like <code>ShlWAPI.dll</code>, because lower-level libraries also depend on this. So it should really either depend on <code>kernel32.dll</code> or <code>ntdll.dll</code> or the like... although I'm having a trouble finding <em>anything</em> at all, whether at a high level or at a low level.</p>
  <h2>Edit:</h2>
  <p>A little experimentation told me that it's the Win32 subsystem (i.e. <code>kernel32.dll</code>... or is it perhaps <code>RtlDosPathNameToNtPathName_U</code> in <code>ntdll.dll</code>? not sure, didn't test...) which converts forward slashes to backslashes, not the kernel. (Prefixing <code>\\?\</code> makes it impossible to use forward slashes later in the path -- and the NT native user-mode API also fails with forward slashes.)</p>
  <p>So apparently it's not quite &quot;built into&quot; Windows, but rather just a compatibility feature -- which means you can't just blindly substitute slashes instead of backslashes, because any program which randomly prefixes <code>\\?\</code> to paths will automatically break on forward slashes.</p>
  <p>I have mixed feelings on what conclusions to make regarding this, but I just thought I'd mention it.</p>
  <p><sub>(I tagged this as &quot;path separator&quot; even though that's technically incorrect because the path separator is used for separating <em>paths</em>, not directories (<code>;</code> vs. <code>\</code>). Hopefully people get what I meant.)</sub></p>