<p>Havn't reviewed yet, but just on the point of actually doing this at all.</p>
<p>Ok, despite what <code>g_utf8_validate ()</code> claims <code>NUL</code> is a UTF-8 code point.  So I suppose there is an argument that it should be loaded. But due the number of C NTS functions used in Geany its pretty much going to be a lottery if it edits, so loading it read-only is a good idea (if display and parse and search and any other function that will access an readonly file is NUL safe). 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>
<p>Showing an infobar identifying that its readonly, and why, allows the user to understand why they can't edit it, and where the problem is an encoding error, to locate where that occurred so they might be able to fix it with a hex editor or similar seems useful.</p>
<p>But why saving it?  Its readonly, so it won't change.  If the problem is encoding, then LOAD it with the correct encoding, don't save a new encoding of an incorrectly decoded file.  If the file has wrong encoding (or mixed encodings) then saving it again won't fix it.</p>
<p>As for editing it, I have yet to see a real use-case for editing such files in a text editor/IDE, and given the amount of changes to Geany it would take to safely allow editing I do not see the point of making any changes to support more than loading and displaying files with NULs until a real use-case is provided.</p>
<p>So unless a compelling use-case is presented I would say load it, and lock it read-only, and tell the user why to help them find the problem, but I do not support starting any changes to allow editing, or saving.</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-349286508">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABDrJ2lwPpUOZwe9JsGDUqJS4ckb1GAgks5s9TM1gaJpZM4Q18TU">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/ABDrJ5H6IDJq3UW-V9Lp8uuLaNlcxwgdks5s9TM1gaJpZM4Q18TU.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-349286508"></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":"@elextr in #1709: Havn't reviewed yet, but just on the point of actually doing this at all.\r\n\r\nOk, despite what `g_utf8_validate ()` claims `NUL` is a UTF-8 code point.  So I suppose there is an argument that it should be loaded. But due the number of C NTS functions used in Geany its pretty much going to be a lottery if it edits, so loading it read-only is a good idea (if display and parse and search and any other function that will access an readonly file is NUL safe). 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\nShowing an infobar identifying that its readonly, and why, allows the user to understand why they can't edit it, and where the problem is an encoding error, to locate where that occurred so they might be able to fix it with a hex editor or similar seems useful.\r\n\r\nBut why saving it?  Its readonly, so it won't change.  If the problem is encoding, then LOAD it with the correct encoding, don't save a new encoding of an incorrectly decoded file.  If the file has wrong encoding (or mixed encodings) then saving it again won't fix it.\r\n\r\nAs for editing it, I have yet to see a real use-case for editing such files in a text editor/IDE, and given the amount of changes to Geany it would take to safely allow editing I do not see the point of making any changes to support more than loading and displaying files with NULs until a real use-case is provided.\r\n\r\nSo unless a compelling use-case is presented I would say load it, and lock it read-only, and tell the user why to help them find the problem, but I do not support starting any changes to allow editing, or saving."}],"action":{"name":"View Pull Request","url":"https://github.com/geany/geany/pull/1709#issuecomment-349286508"}}}</script>