<blockquote>
<p>But thats only loading files as UTF-8, any other encoding is going to depend on the system iconv implementation underlying the <code>g_convert()</code></p>
</blockquote>
<p>Indeed, but I feel like those are somewhat likely to support whichever bytes, as it's basically the point in converting encodings -- but indeed I don't know.  And on my system it seems like it does work fine for what I tested.</p>
<blockquote>
<p>But why saving it? Its readonly, so it won't change.</p>
</blockquote>
<p>All I did is fix it so it works, mostly because it was so easy -- and there was a very simple but weird bug in there not only easy to fix but also very confusing when looking at the code.  So no, my idea was not to suggest we can work fully with files embedding NUL bytes and that then we need to be able to save them, but that why not fix this very important part for any future possibility in that area if it's so easy anyway.<br>
And encoding issue when saving will be the very same with NULs as any other byte: if the converter is happy with them it'll work, otherwise it won't.  The problem was that UTF-8 files were artificially truncated at the first NUL, but actually non-UTF-8 were fine embedding NULs – which actually is likely to be important because I would imagine some encodings might generate NUL bytes in their encoded stream anyway (or at least could anyway).</p>
<p>Anyway: what I fixed was simply that now we properly write the whole thing in any case, with no corner case doing otherwise.</p>
<blockquote>
<p>The obvious one that comes to mind is actually fixing the file by removing the NUL, which IIRC Scintilla helpfully displays using a special little icon/glyph.</p>
</blockquote>
<p>Yes (like <a href="https://github.com/geany/geany/issues/1708" class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="279102732" data-permission-text="Issue title is private" data-url="https://github.com/geany/geany/issues/1708">#1708</a>), and yes (it displays it like any other control character, in a little box with the character name). And again, regex search actually works pretty OK with NULs, you can actually search for NUL bytes with them.  Non-regex search doesn't, however (could be interesting to fix, but for now it's out of the scope of this).</p>
<p>Anyway, despite the "WIP" label, I don't really plan on working on fixing everything so it accepts NULs. I started it to see how hard it would be to at least simply load such files properly so one could look at them, also thinking that if that part is done it's more likely anyone would work on fixing some other code to handle those.<br>
So <a href="https://github.com/elextr" class="user-mention">@elextr</a> I think the goal of this PR matches your hopes: loading files, but nothing else -- and warning users it's not properly supported and can cause issues.  But if one day we end up with full support for those, I don't think it would be a bad thing.</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/1709#issuecomment-349418916">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABDrJxdsRrs7TKcnIBQ59WlW0PxgEWswks5s9Z00gaJpZM4Q18TU">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/ABDrJ_xTsCHBjS7NVtWtU5awEiHFFz31ks5s9Z00gaJpZM4Q18TU.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/1709#issuecomment-349418916"></link>
  <meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>

<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/geany/geany","title":"geany/geany","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/geany/geany"}},"updates":{"snippets":[{"icon":"PERSON","message":"@b4n in #1709: \u003e But thats only loading files as UTF-8, any other encoding is going to depend on the system iconv implementation underlying the `g_convert()`\r\n\r\nIndeed, but I feel like those are somewhat likely to support whichever bytes, as it's basically the point in converting encodings -- but indeed I don't know.  And on my system it seems like it does work fine for what I tested.\r\n\r\n\u003e But why saving it? Its readonly, so it won't change.\r\n\r\nAll I did is fix it so it works, mostly because it was so easy -- and there was a very simple but weird bug in there not only easy to fix but also very confusing when looking at the code.  So no, my idea was not to suggest we can work fully with files embedding NUL bytes and that then we need to be able to save them, but that why not fix this very important part for any future possibility in that area if it's so easy anyway.\r\nAnd encoding issue when saving will be the very same with NULs as any other byte: if the converter is happy with them it'll work, otherwise it won't.  The problem was that UTF-8 files were artificially truncated at the first NUL, but actually non-UTF-8 were fine embedding NULs – which actually is likely to be important because I would imagine some encodings might generate NUL bytes in their encoded stream anyway (or at least could anyway).\r\n\r\nAnyway: what I fixed was simply that now we properly write the whole thing in any case, with no corner case doing otherwise.\r\n\r\n\u003e The obvious one that comes to mind is actually fixing the file by removing the NUL, which IIRC Scintilla helpfully displays using a special little icon/glyph.\r\n\r\nYes (like #1708), and yes (it displays it like any other control character, in a little box with the character name). And again, regex search actually works pretty OK with NULs, you can actually search for NUL bytes with them.  Non-regex search doesn't, however (could be interesting to fix, but for now it's out of the scope of this).\r\n\r\nAnyway, despite the \"WIP\" label, I don't really plan on working on fixing everything so it accepts NULs. I started it to see how hard it would be to at least simply load such files properly so one could look at them, also thinking that if that part is done it's more likely anyone would work on fixing some other code to handle those.\r\nSo @elextr I think the goal of this PR matches your hopes: loading files, but nothing else -- and warning users it's not properly supported and can cause issues.  But if one day we end up with full support for those, I don't think it would be a bad thing."}],"action":{"name":"View Pull Request","url":"https://github.com/geany/geany/pull/1709#issuecomment-349418916"}}}</script>