title: escaping string on Windows command line
body: <p>I'm trying to pass string to Win32 program from command line so it will be printed without changes.</p>
  
  <p>Why I have to escape<br>
  <strong>"AAA &lt;BBB@pobox.com&gt;"</strong> as <strong>"""AAA &lt;BBB@pobox.com&gt;"""</strong><br>
  but<br>
  <strong>"AAA &lt;BBB@pobox.com&gt;",</strong> (comma included) as <strong>"\"AAA ^&lt;BBB@pobox.com^&gt;\","</strong><br></p>
  
  <p>I see no consistency in escaping rules for windows command line</p>
  
  <p>P.S. I'm trying to generate a .cmd file</p>
  
  <p>Update:</p>
  
  <p>I'm using simple C program for testing that is compiled with gcc, no additional object files linked. If I replace it with perl, rules remain same.</p>
  
  <p>I'm trying to create a general escaping algorithm. It will generate .cmd file which will call perl with output redirect. Currently I have a problem that if string contains odd number of double quotes which are escaped with backslash, output redirect does not function. Same problem is described in the last comment to <a href="http://blogs.msdn.com/b/oldnewthing/archive/2010/09/17/10063629.aspx" rel="nofollow">http://blogs.msdn.com/b/oldnewthing/archive/2010/09/17/10063629.aspx</a> .</p>
  
  <p>If I use "" as escape for ", it splits on space, so it will result it 2 parameters instead of one. Also "" has some artifacts.</p>