<br><br><div class="gmail_quote">On Thu, Jun 24, 2010 at 11:42 PM, Roman Cheplyaka <span dir="ltr">&lt;<a href="mailto:roma@ro-che.info">roma@ro-che.info</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
* Jason Dagit &lt;<a href="mailto:dagit@codersbase.com">dagit@codersbase.com</a>&gt; [2010-06-24 20:52:03-0700]<br>
<div><div></div><div class="h5">&gt; On Sat, Jun 19, 2010 at 1:06 AM, Roman Cheplyaka &lt;<a href="mailto:roma@ro-che.info">roma@ro-che.info</a>&gt; wrote:<br>
&gt;<br>
&gt; &gt; While ghc 6.12 finally has proper locale support, core packages (such as<br>
&gt; &gt; unix) still use withCString and therefore work incorrectly when argument<br>
&gt; &gt; (e.g. file path) is not ASCII.<br>
&gt; &gt;<br>
&gt;<br>
&gt; Pardon me if I&#39;m misunderstanding withCString, but my understanding of unix<br>
&gt; paths is that they are to be treated as strings of bytes.  That is, unlike<br>
&gt; windows, they do not have an encoding predefined.  Furthermore, you could<br>
&gt; have two filepaths in the same directory with different encodings due to<br>
&gt; this.<br>
&gt;<br>
&gt; In this case, what would be the correct way of handling the paths?<br>
&gt;  Converting to a Haskell String would require knowing the encoding, right?<br>
&gt;  My reasoning is that Haskell Char type is meant to correspond to code<br>
&gt; points so putting them into a string means you have to know their code point<br>
&gt; which is different from their (multi-)byte value right?<br>
&gt;<br>
&gt; Perhaps I have some details wrong?  If so, please clarify.<br>
<br>
</div></div>Jason,<br>
<br>
you got everything right here. So, as you said, there is a mismatch<br>
between representation in Haskell (list of code points) and<br>
representation in the operating system (list of bytes), so we need to<br>
know the encoding. Encoding is supplied by the user via locale<br>
(<a href="https://secure.wikimedia.org/wikipedia/en/wiki/Locale" target="_blank">https://secure.wikimedia.org/wikipedia/en/wiki/Locale</a>), particularly<br>
LC_CTYPE variable.<br>
<br>
The problem with encodings is not new -- it was already solved e.g. for<br>
input/output.<br></blockquote><div><br></div><div>This is the part where I don&#39;t understand the problem well.  I thought that with IO the program assumes the locale of the environment but that with filepaths you don&#39;t know what locale (more specifically which encoding) they were created with.  So if you try to treat them as having the locale of the current environment you run the risk of misunderstanding their encoding.</div>
<div><br></div><div>Jason</div></div>