<br><div class="gmail_quote">On Wed, Mar 30, 2011 at 11:01, Alistair Bayley <span dir="ltr">&lt;<a href="mailto:alistair@abayley.org">alistair@abayley.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div class="im">On 30 March 2011 20:53, Max Bolingbroke <span dir="ltr">&lt;<a href="mailto:batterseapower@hotmail.com" target="_blank">batterseapower@hotmail.com</a>&gt;</span> wrote:<br></div><div class="gmail_quote"><div class="im">

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div>On 30 March 2011 07:52, Michael Snoyman &lt;<a href="mailto:michael@snoyman.com" target="_blank">michael@snoyman.com</a>&gt; wrote:<br>
&gt; I could<br>
&gt; manually do something like (utf8Decode . S8.pack), but that presumes<br>
&gt; that the character encoding on the system in question is UTF8. So two<br>
&gt; questions:<br>
<br>
</div>Funnily enough I have been thinking about this quite hard recently,<br>
and the situation is kind of a mess and short of implementing PEP383<br>
(<a href="http://www.python.org/dev/peps/pep-0383/" target="_blank">http://www.python.org/dev/peps/pep-0383/</a>) in GHC I can&#39;t see how to<br>
make it easier on the programmer. As Jason points out the best you can<br>
really do is probably:<br>
<br>
 1. Treat Strings that represent filenames as raw byte sequences, even<br>
though they claim to be strings<br>
<br>
 2. When presenting such Strings to the user, re-decode them by using<br>
the current locale encoding (which will typically be UTF-8). You<br>
probably want to have some means of avoiding decoding errors here too<br>
-- ignoring or replacing undecodable bytes -- but presently this is<br>
not so straightforward. If you happen to be on a system with GNU Iconv<br>
you can use it&#39;s &quot;C//TRANSLIT//IGNORE&quot; encoding to achieve this,<br>
however.<br></blockquote><div><br></div><div><br></div></div><div><a href="http://www.haskell.org/pipermail/libraries/2009-August/012493.html" target="_blank">http://www.haskell.org/pipermail/libraries/2009-August/012493.html</a></div>

<div><br>
</div><div>I took from this discussion that FilePath really should be a pair of the actual filename ByteString, and the printable String (decoded from the ByteString, with encoding specified by the user&#39;s locale). The conversion from ByteString to String (and vice versa) is not guaranteed to be lossless, so you need to remember both.</div>



<div><br></div></div></blockquote><div><br></div><div>I&#39;m not sure that  I agree with that. Why does it have to be loss-less?</div><div>The problem, more likely, is the fact that FilePath is just a simple string.</div>

<div>Maybe we should go the way of Java where cross-platform file access is based upon a File (or the new Path) type? That way the internal representation could use whatever necessary to ensure a unique reference to a file or directory while at the same time providing a way to get a human-readable representation.</div>

<div>Going from strings to file/path types would need the correct encodings to work.</div><div><br></div><div>Cheers,</div><div> -Tako</div><div><br></div><div>PS: Just lurking here most of the time because I&#39;m still a total Haskell noob, you can ignore me without risk.</div>

<div><br></div></div><br>