<h1 dir="auto">Environment</h1>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Windows build number: 10.0.18362.175
Windows Terminal version (if applicable): 0.2.1715.0

Any other software: Visual Studio 2017 (I guess it fails with other VS versions)"><pre lang="none" class="notranslate"><code class="notranslate">Windows build number: 10.0.18362.175
Windows Terminal version (if applicable): 0.2.1715.0

Any other software: Visual Studio 2017 (I guess it fails with other VS versions)
</code></pre></div>
<h1 dir="auto">Steps to reproduce</h1>
<p dir="auto">Add this entry to <code class="notranslate">profile.json</code>:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="        {
            &quot;acrylicOpacity&quot; : 0.75,
            &quot;closeOnExit&quot; : true,
            &quot;colorScheme&quot; : &quot;Campbell&quot;,
            &quot;commandline&quot; : &quot;cmd.exe /k \&quot;%PROGRAMFILES(X86)%\\Microsoft Visual Studio\\2017\\Community\\Common7\\Tools\\VsDevCmd.bat\&quot;&quot;,
            &quot;cursorColor&quot; : &quot;#FFFFFF&quot;,
            &quot;cursorShape&quot; : &quot;bar&quot;,
            &quot;fontFace&quot; : &quot;Consolas&quot;,
            &quot;fontSize&quot; : 10,
            &quot;guid&quot; : &quot;{1748ecca-abdd-4aa4-bcc4-9fca0d045be5}&quot;,
            &quot;historySize&quot; : 9001,
            &quot;icon&quot; : &quot;ms-appx:///ProfileIcons/{0caa0dad-35be-5f56-a8ff-afceeeaa6101}.png&quot;,
            &quot;name&quot; : &quot;VS cmd&quot;,
            &quot;padding&quot; : &quot;0, 0, 0, 0&quot;,
            &quot;snapOnInput&quot; : true,
            &quot;startingDirectory&quot; : &quot;%USERPROFILE%&quot;,
            &quot;useAcrylic&quot; : true
        },"><pre class="notranslate"><code class="notranslate">        {
            "acrylicOpacity" : 0.75,
            "closeOnExit" : true,
            "colorScheme" : "Campbell",
            "commandline" : "cmd.exe /k \"%PROGRAMFILES(X86)%\\Microsoft Visual Studio\\2017\\Community\\Common7\\Tools\\VsDevCmd.bat\"",
            "cursorColor" : "#FFFFFF",
            "cursorShape" : "bar",
            "fontFace" : "Consolas",
            "fontSize" : 10,
            "guid" : "{1748ecca-abdd-4aa4-bcc4-9fca0d045be5}",
            "historySize" : 9001,
            "icon" : "ms-appx:///ProfileIcons/{0caa0dad-35be-5f56-a8ff-afceeeaa6101}.png",
            "name" : "VS cmd",
            "padding" : "0, 0, 0, 0",
            "snapOnInput" : true,
            "startingDirectory" : "%USERPROFILE%",
            "useAcrylic" : true
        },
</code></pre></div>
<h1 dir="auto">Expected behavior</h1>
<p dir="auto">Initializes the <a href="https://docs.microsoft.com/en-us/dotnet/framework/tools/developer-command-prompt-for-vs" rel="nofollow">Developer Command prompt for visual studio</a></p>
<h1 dir="auto">Actual behavior</h1>
<p dir="auto">The batch script does not executes and fails like this:</p>
<p dir="auto">'C:\Program' is not recognized as an internal or external command,<br>
operable program or batch file.</p>
<h1 dir="auto">Environment</h1>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Windows build number: [run &quot;ver&quot; at a command prompt]
Windows Terminal version (if applicable):

Any other software?"><pre lang="none" class="notranslate"><code class="notranslate">Windows build number: [run "ver" at a command prompt]
Windows Terminal version (if applicable):

Any other software?
</code></pre></div>
<p dir="auto">Today I modified the Windows Terminal configuration file and wanted to create a Pwsh with the emoji title. However, I encountered some confusion in this process. I checked the task manager and found that conhost did not escape when the process was started, causing the command line to parse the exception.</p>
<h1 dir="auto">Steps to reproduce</h1>

<h1 dir="auto">Expected behavior</h1>

<p dir="auto">I need to start pwsh by the following command line (note that the following command line is in cmd, or you can start pwsh normally using CreateProcessW.)</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&quot;C:\Program Files\PowerShell\7-preview\pwsh.exe&quot; -NoExit -Command &quot;$Host.UI.RawUI.WindowTitle=\&quot;Windows Pwsh 💙 (7 Preview)\&quot;&quot;"><pre class="notranslate"><code class="notranslate">"C:\Program Files\PowerShell\7-preview\pwsh.exe" -NoExit -Command "$Host.UI.RawUI.WindowTitle=\"Windows Pwsh 💙 (7 Preview)\""
</code></pre></div>
<p dir="auto">Here is the Windows Terminal configuration file (the command line has been properly escaped):</p>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="        {
            &quot;startingDirectory&quot;: &quot;C:\\Users\\CharlieInc&quot;,
            &quot;guid&quot;: &quot;{08a0be98-ff68-4e3a-a054-0fbd3969d3bb}&quot;,
            &quot;name&quot;: &quot;Windows Pwsh 💙 (7 Preview)&quot;,
            &quot;colorscheme&quot;: &quot;Campbell&quot;,
            &quot;historySize&quot;: 9001,
            &quot;snapOnInput&quot;: true,
            &quot;cursorColor&quot;: &quot;#FFFFFF&quot;,
            &quot;cursorShape&quot;: &quot;bar&quot;,
            &quot;commandline&quot;: &quot;\&quot;C:\\Program Files\\PowerShell\\7-preview\\pwsh.exe\&quot; -NoExit -Command \&quot;$Host.UI.RawUI.WindowTitle=\\\&quot;Windows Pwsh 💙 (7 Preview)\\\&quot;\&quot;&quot;,
            &quot;fontFace&quot;: &quot;Consolas&quot;,
            &quot;fontSize&quot;: 12,
            &quot;acrylicOpacity&quot;: 0.75,
            &quot;useAcrylic&quot;: true,
            &quot;closeOnExit&quot;: false,
            &quot;padding&quot;: &quot;0, 0, 0, 0&quot;,
            &quot;icon&quot;: &quot;ms-appdata:///roaming/pwsh-32.png&quot;
        }"><pre class="notranslate">        {
            <span class="pl-ent">"startingDirectory"</span>: <span class="pl-s"><span class="pl-pds">"</span>C:<span class="pl-cce">\\</span>Users<span class="pl-cce">\\</span>CharlieInc<span class="pl-pds">"</span></span>,
            <span class="pl-ent">"guid"</span>: <span class="pl-s"><span class="pl-pds">"</span>{08a0be98-ff68-4e3a-a054-0fbd3969d3bb}<span class="pl-pds">"</span></span>,
            <span class="pl-ent">"name"</span>: <span class="pl-s"><span class="pl-pds">"</span>Windows Pwsh 💙 (7 Preview)<span class="pl-pds">"</span></span>,
            <span class="pl-ent">"colorscheme"</span>: <span class="pl-s"><span class="pl-pds">"</span>Campbell<span class="pl-pds">"</span></span>,
            <span class="pl-ent">"historySize"</span>: <span class="pl-c1">9001</span>,
            <span class="pl-ent">"snapOnInput"</span>: <span class="pl-c1">true</span>,
            <span class="pl-ent">"cursorColor"</span>: <span class="pl-s"><span class="pl-pds">"</span>#FFFFFF<span class="pl-pds">"</span></span>,
            <span class="pl-ent">"cursorShape"</span>: <span class="pl-s"><span class="pl-pds">"</span>bar<span class="pl-pds">"</span></span>,
            <span class="pl-ent">"commandline"</span>: <span class="pl-s"><span class="pl-pds">"</span><span class="pl-cce">\"</span>C:<span class="pl-cce">\\</span>Program Files<span class="pl-cce">\\</span>PowerShell<span class="pl-cce">\\</span>7-preview<span class="pl-cce">\\</span>pwsh.exe<span class="pl-cce">\"</span> -NoExit -Command <span class="pl-cce">\"</span>$Host.UI.RawUI.WindowTitle=<span class="pl-cce">\\\"</span>Windows Pwsh 💙 (7 Preview)<span class="pl-cce">\\\"\"</span><span class="pl-pds">"</span></span>,
            <span class="pl-ent">"fontFace"</span>: <span class="pl-s"><span class="pl-pds">"</span>Consolas<span class="pl-pds">"</span></span>,
            <span class="pl-ent">"fontSize"</span>: <span class="pl-c1">12</span>,
            <span class="pl-ent">"acrylicOpacity"</span>: <span class="pl-c1">0.75</span>,
            <span class="pl-ent">"useAcrylic"</span>: <span class="pl-c1">true</span>,
            <span class="pl-ent">"closeOnExit"</span>: <span class="pl-c1">false</span>,
            <span class="pl-ent">"padding"</span>: <span class="pl-s"><span class="pl-pds">"</span>0, 0, 0, 0<span class="pl-pds">"</span></span>,
            <span class="pl-ent">"icon"</span>: <span class="pl-s"><span class="pl-pds">"</span>ms-appdata:///roaming/pwsh-32.png<span class="pl-pds">"</span></span>
        }</pre></div>
<h1 dir="auto">Actual behavior</h1>
<p dir="auto">As expected, Pwsh should set the title correctly, but pwsh reported the error:<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/6904176/58741634-e7558300-844d-11e9-9b7e-dcdff905ffa3.png"><img src="https://user-images.githubusercontent.com/6904176/58741634-e7558300-844d-11e9-9b7e-dcdff905ffa3.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto">Let's take a look at the command line:</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/6904176/58741674-49ae8380-844e-11e9-9ca4-43ce9bf4b1ab.png"><img src="https://user-images.githubusercontent.com/6904176/58741674-49ae8380-844e-11e9-9ca4-43ce9bf4b1ab.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/6904176/58741666-38657700-844e-11e9-8711-e813c22bc137.png"><img src="https://user-images.githubusercontent.com/6904176/58741666-38657700-844e-11e9-8711-e813c22bc137.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto">When you see the red line, the command line that pwsh starts is incorrect, and when you start conhost, the command line is still correct!</p>

<p dir="auto">Currently I have found a suspicious code, most likely this code caused an error:</p>
<p dir="auto"></p><div class="Box Box--condensed my-2">
  <div class="Box-header f6">
    <p class="mb-0 text-bold">
      <a href="https://github.com/microsoft/terminal/blob/71e19cd82528d66a0a7867cbed85990cfc1685f1/src/host/ConsoleArguments.cpp#L263-L288">terminal/src/host/ConsoleArguments.cpp</a>
    </p>
    <p class="mb-0 color-fg-muted">
        Lines 263 to 288
      in
      <a data-pjax="true" class="commit-tease-sha" href="/microsoft/terminal/commit/71e19cd82528d66a0a7867cbed85990cfc1685f1">71e19cd</a>
    </p>
  </div>
  <div itemprop="text" class="Box-body p-0 blob-wrapper blob-wrapper-embedded data">
    <table class="highlight tab-size mb-0 js-file-line-container" data-tab-size="8" data-paste-markdown-skip="">

        <tbody><tr class="border-0">
          <td id="L263" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="263"></td>
          <td id="LC263" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> HRESULT <span class="pl-en">ConsoleArguments::_GetClientCommandline</span>(_Inout_ std::vector&lt;std::wstring&gt;&amp; args, <span class="pl-k">const</span> <span class="pl-c1">size_t</span> index, <span class="pl-k">const</span> <span class="pl-k">bool</span> skipFirst) </td>
        </tr>

        <tr class="border-0">
          <td id="L264" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="264"></td>
          <td id="LC264" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> { </td>
        </tr>

        <tr class="border-0">
          <td id="L265" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="265"></td>
          <td id="LC265" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-k">auto</span> start = args.<span class="pl-c1">begin</span>()+<span class="pl-c1">index</span>; </td>
        </tr>

        <tr class="border-0">
          <td id="L266" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="266"></td>
          <td id="LC266" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">  </td>
        </tr>

        <tr class="border-0">
          <td id="L267" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="267"></td>
          <td id="LC267" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-c"><span class="pl-c">//</span> Erase the first token.</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L268" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="268"></td>
          <td id="LC268" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-c"><span class="pl-c">//</span>  Used to get rid of the explicit commandline token "--"</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L269" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="269"></td>
          <td id="LC269" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-k">if</span> (skipFirst) </td>
        </tr>

        <tr class="border-0">
          <td id="L270" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="270"></td>
          <td id="LC270" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     { </td>
        </tr>

        <tr class="border-0">
          <td id="L271" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="271"></td>
          <td id="LC271" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">         <span class="pl-c"><span class="pl-c">//</span> Make sure that the arg we're deleting is "--"</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L272" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="272"></td>
          <td id="LC272" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">         <span class="pl-c1">FAIL_FAST_IF</span>(!(CLIENT_COMMANDLINE_ARG == start-&gt;<span class="pl-c1">c_str</span>())); </td>
        </tr>

        <tr class="border-0">
          <td id="L273" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="273"></td>
          <td id="LC273" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">         args.<span class="pl-c1">erase</span>(start); </td>
        </tr>

        <tr class="border-0">
          <td id="L274" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="274"></td>
          <td id="LC274" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     } </td>
        </tr>

        <tr class="border-0">
          <td id="L275" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="275"></td>
          <td id="LC275" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">  </td>
        </tr>

        <tr class="border-0">
          <td id="L276" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="276"></td>
          <td id="LC276" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     _clientCommandline = <span class="pl-s"><span class="pl-pds">L"</span><span class="pl-pds">"</span></span>; </td>
        </tr>

        <tr class="border-0">
          <td id="L277" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="277"></td>
          <td id="LC277" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-c1">size_t</span> j = <span class="pl-c1">0</span>; </td>
        </tr>

        <tr class="border-0">
          <td id="L278" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="278"></td>
          <td id="LC278" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-k">for</span> (j = <span class="pl-c1">index</span>; j &lt; args.<span class="pl-c1">size</span>(); j++) </td>
        </tr>

        <tr class="border-0">
          <td id="L279" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="279"></td>
          <td id="LC279" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     { </td>
        </tr>

        <tr class="border-0">
          <td id="L280" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="280"></td>
          <td id="LC280" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">         _clientCommandline += args[j]; </td>
        </tr>

        <tr class="border-0">
          <td id="L281" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="281"></td>
          <td id="LC281" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">         <span class="pl-k">if</span> (j+<span class="pl-c1">1</span> &lt; args.<span class="pl-c1">size</span>()) </td>
        </tr>

        <tr class="border-0">
          <td id="L282" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="282"></td>
          <td id="LC282" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">         { </td>
        </tr>

        <tr class="border-0">
          <td id="L283" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="283"></td>
          <td id="LC283" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">             _clientCommandline += <span class="pl-s"><span class="pl-pds">L"</span> <span class="pl-pds">"</span></span>; </td>
        </tr>

        <tr class="border-0">
          <td id="L284" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="284"></td>
          <td id="LC284" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">         } </td>
        </tr>

        <tr class="border-0">
          <td id="L285" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="285"></td>
          <td id="LC285" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     } </td>
        </tr>

        <tr class="border-0">
          <td id="L286" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="286"></td>
          <td id="LC286" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     args.<span class="pl-c1">erase</span>(args.<span class="pl-c1">begin</span>()+<span class="pl-c1">index</span>, args.<span class="pl-c1">begin</span>()+j); </td>
        </tr>

        <tr class="border-0">
          <td id="L287" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="287"></td>
          <td id="LC287" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">  </td>
        </tr>

        <tr class="border-0">
          <td id="L288" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="288"></td>
          <td id="LC288" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-k">return</span> S_OK; </td>
        </tr>
    </tbody></table>
  </div>
</div>
<p></p>
<p dir="auto">In this code, command line composition is simply a simple connection rather than a concatenated string. If the string contains spaces, this will result in an incorrect command line.</p>
<p dir="auto">Below is a code for the command line escaping, which may be useful：</p>
<div class="highlight highlight-source-c++ notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="inline std::wstring escape_argument(std::wstring_view ac) {
  if (ac.empty()) {
    return L&quot;\&quot;\&quot;&quot;;
  }
  bool hasspace = false;
  auto n = ac.size();
  for (auto c : ac) {
    switch (c) {
    case L'&quot;':
    case L'\\':
      n++;
      break;
    case ' ':
    case '\t':
      hasspace = true;
      break;
    default:
      break;
    }
  }
  if (hasspace) {
    n += 2;
  }
  if (n == ac.size()) {
    return std::wstring(ac.data(), ac.size());
  }
  std::wstring buf;
  if (hasspace) {
    buf.push_back(L'&quot;');
  }
  size_t slashes = 0;
  for (auto c : ac) {
    switch (c) {
    case L'\\':
      slashes++;
      buf.push_back(L'\\');
      break;
    case L'&quot;': {
      for (; slashes &gt; 0; slashes--) {
        buf.push_back(L'\\');
      }
      buf.push_back(L'\\');
      buf.push_back(c);
    } break;
    default:
      slashes = 0;
      buf.push_back(c);
      break;
    }
  }
  if (hasspace) {
    for (; slashes &gt; 0; slashes--) {
      buf.push_back(L'\\');
    }
    buf.push_back(L'&quot;');
  }
  return buf;
}"><pre class="notranslate"><span class="pl-k">inline</span> std::wstring <span class="pl-en">escape_argument</span>(std::wstring_view ac) {
  <span class="pl-k">if</span> (ac.<span class="pl-c1">empty</span>()) {
    <span class="pl-k">return</span> <span class="pl-s"><span class="pl-pds">L"</span><span class="pl-cce">\"\"</span><span class="pl-pds">"</span></span>;
  }
  <span class="pl-k">bool</span> hasspace = <span class="pl-c1">false</span>;
  <span class="pl-k">auto</span> n = ac.<span class="pl-c1">size</span>();
  <span class="pl-k">for</span> (<span class="pl-k">auto</span> c : ac) {
    <span class="pl-k">switch</span> (c) {
    <span class="pl-k">case</span> L<span class="pl-s"><span class="pl-pds">'</span>"<span class="pl-pds">'</span></span>:
    <span class="pl-k">case</span> L<span class="pl-s"><span class="pl-pds">'</span><span class="pl-cce">\\</span><span class="pl-pds">'</span></span>:
      n++;
      <span class="pl-k">break</span>;
    <span class="pl-k">case</span> <span class="pl-s"><span class="pl-pds">'</span> <span class="pl-pds">'</span></span>:
    <span class="pl-k">case</span> <span class="pl-s"><span class="pl-pds">'</span><span class="pl-cce">\t</span><span class="pl-pds">'</span></span>:
      hasspace = <span class="pl-c1">true</span>;
      <span class="pl-k">break</span>;
    <span class="pl-k">default</span>:
      <span class="pl-k">break</span>;
    }
  }
  <span class="pl-k">if</span> (hasspace) {
    n += <span class="pl-c1">2</span>;
  }
  <span class="pl-k">if</span> (n == ac.<span class="pl-c1">size</span>()) {
    <span class="pl-k">return</span> <span class="pl-c1">std::wstring</span>(ac.<span class="pl-c1">data</span>(), ac.<span class="pl-c1">size</span>());
  }
  std::wstring buf;
  <span class="pl-k">if</span> (hasspace) {
    buf.<span class="pl-c1">push_back</span>(L<span class="pl-s"><span class="pl-pds">'</span>"<span class="pl-pds">'</span></span>);
  }
  <span class="pl-c1">size_t</span> slashes = <span class="pl-c1">0</span>;
  <span class="pl-k">for</span> (<span class="pl-k">auto</span> c : ac) {
    <span class="pl-k">switch</span> (c) {
    <span class="pl-k">case</span> L<span class="pl-s"><span class="pl-pds">'</span><span class="pl-cce">\\</span><span class="pl-pds">'</span></span>:
      slashes++;
      buf.<span class="pl-c1">push_back</span>(L<span class="pl-s"><span class="pl-pds">'</span><span class="pl-cce">\\</span><span class="pl-pds">'</span></span>);
      <span class="pl-k">break</span>;
    <span class="pl-k">case</span> L<span class="pl-s"><span class="pl-pds">'</span>"<span class="pl-pds">'</span></span>: {
      <span class="pl-k">for</span> (; slashes &gt; <span class="pl-c1">0</span>; slashes--) {
        buf.<span class="pl-c1">push_back</span>(L<span class="pl-s"><span class="pl-pds">'</span><span class="pl-cce">\\</span><span class="pl-pds">'</span></span>);
      }
      buf.<span class="pl-c1">push_back</span>(L<span class="pl-s"><span class="pl-pds">'</span><span class="pl-cce">\\</span><span class="pl-pds">'</span></span>);
      buf.<span class="pl-c1">push_back</span>(c);
    } <span class="pl-k">break</span>;
    <span class="pl-k">default</span>:
      slashes = <span class="pl-c1">0</span>;
      buf.<span class="pl-c1">push_back</span>(c);
      <span class="pl-k">break</span>;
    }
  }
  <span class="pl-k">if</span> (hasspace) {
    <span class="pl-k">for</span> (; slashes &gt; <span class="pl-c1">0</span>; slashes--) {
      buf.<span class="pl-c1">push_back</span>(L<span class="pl-s"><span class="pl-pds">'</span><span class="pl-cce">\\</span><span class="pl-pds">'</span></span>);
    }
    buf.<span class="pl-c1">push_back</span>(L<span class="pl-s"><span class="pl-pds">'</span>"<span class="pl-pds">'</span></span>);
  }
  <span class="pl-k">return</span> buf;
}</pre></div>