<p>I completely agree on current state about encodings is far from what it should be. Though I guess we won't get it in a much better shape so close to a release.</p>

<p>Regarding the correct place in spawn.c:spawn_async_with_pipes():<br>
I just added a commit which also converts the command string to be executed, as it is affected in the same way.<br>
But also a check to perform the conversion only if the input string is valid UTF-8. Consider this as some kind of compability layer, if any caller passes an already locale-encoded string in, it won't be touched.<br>
Still I think, this place is not that wrong, at least on Windows, because usually we say: "use <code>utils_get_locale_from_utf8</code> everywhere!" and on Windows this is just a no-op. This is OK for almost all places, especially when dealing with filenames and the GLib file API.<br>
<em>But</em> it is wrong when using the Windows API directly which we do here (<code>CreateProcess</code>) and why should a caller think about this?<br>
The caller just puts the string as returned from <code>utils_get_locale_from_utf8</code> into the spawn_ API and doesn't need to know about the fact that on Windows here we actually need real locale encoding and not just UTF-8.<br>
The only drawback is probably a few unnecessary string duplications but I could live with this.</p>

<p>Regarding cmd.exe and the generated batch script:</p>

<blockquote>
<p>(same in the batch script, if a locale-encoded directory name can work, better use that than play with the codepage I guess)<br>
Agreed. Unfortunately, a locale-encoded directory won't work here. For some reason, there is a difference with cmd.exe. On my system, the system locale is Windows-1252 but cmd.exe uses CP850. So if I would encode the directory into the system locale, cmd.exe won't accept it.<br>
But if I convert the whole script content into the system codepage, it works fine. This is what I did in <a href="https://github.com/geany/geany/commit/a95f174fe1ab0707c8fc092fceb9294cb92123b3" class="commit-link"><tt>a95f174</tt></a> to get rid of the ugly <code>chcp</code> thing. So we also convert the program/script filename which is to be executed, as it is affected in the same way, as mentioned above.<br>
And as in the changes mentioned above for spawn.c, here the codepage conversion is also only performed if the input string is valid UTF-8.</p>
</blockquote>

<p>While this is all far from perfect and need to be solved more generally, I think it's a first step in getting solved known problems (<a href="https://github.com/geany/geany/issues/1076" class="issue-link js-issue-link" data-url="https://github.com/geany/geany/issues/1076" data-id="160793266" data-error-text="Failed to load issue title" data-permission-text="Issue title is private">#1076</a>).</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/geany/geany/pull/1095#issuecomment-229077233">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe/ABDrJ9VTZkumeUiwd3SWu6O9Ek9DJwbNks5qQTePgaJpZM4I_lTo">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/ABDrJ4qXYNXCQJRN9K9PnWnI-pDtIFRuks5qQTePgaJpZM4I_lTo.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/geany/geany/pull/1095#issuecomment-229077233"></link>
  <meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>