<div class="gmail_quote">I'm trying to fix unicode file handling on windows <a href="http://llvm.org/bugs/show_bug.cgi?id=10348" target="_blank">http://llvm.org/bugs/show_bug.cgi?id=10348</a>. This currently doesn't work because argv is encoded as multibyte string (clang project is configured this way). </div>

<div class="gmail_quote"><div><br></div>
<div>Michael suggested converting command line to utf8, and this indeed solves the error that the driver emits, but there is another check in CompilerInstance that fails because FileSystemStatCache::get calls ::open and I'm guessing that this function is not smart enough to handle utf8 path on windows? Any ideas?</div>


<div><br></div><div>I have one more question. I added MultibyteToUTF8 function to PathV2.inc (windows version) and now I'd like to call it from ExpandArgv (driver.cpp) but this code is platform specific and isn't visible (function is inside anonymous namespace). I could create a wrapper function that calls this function on windows and does nothing on other platforms. Is this the way to go, and where should I put it (llvm::sys::fs, llvm::sys::path or somewhere else)?</div>

<div><div></div><div class="h5">
<div><br></div><div><div><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">Michael Spencer</b> <span dir="ltr"><<a href="mailto:bigcheesegs@gmail.com" target="_blank">bigcheesegs@gmail.com</a>></span><br>


Date: Sat, Jul 16, 2011 at 12:32 AM<br>Subject: Re: Question regarding Clang path handling on Windows<br>To: Nikola Smiljanic <<a href="mailto:popizdeh@gmail.com" target="_blank">popizdeh@gmail.com</a>><br><br><br>

<div><div></div><div>
On Thu, Jul 14, 2011 at 8:25 AM, Nikola Smiljanic <<a href="mailto:popizdeh@gmail.com" target="_blank">popizdeh@gmail.com</a>> wrote:<br>
> Hi Michael I'd like to fix this bug if I<br>
> can <a href="http://llvm.org/bugs/show_bug.cgi?id=10348" target="_blank">http://llvm.org/bugs/show_bug.cgi?id=10348</a>. Started looking around and I<br>
> think I know where the problem is (your name showed up in svn log for<br>
> PathV2.inc), but I'm not sure what is the right way to solve it. Namely, the<br>
> check in Driver::BuildActions (line 772) fails. It seems<br>
> that function llvm::sys::fs::exists tries to convert input string from utf8<br>
> to utf16, but clang.exe  is compiled with Multibyte Character Sets. This<br>
> means that the conversion will succeed when you pass an ANSI string that is<br>
> also a valid utf8 string. But if you try to pass in some Chinese characters<br>
> you'll get a single byte character string that is interpreted using the<br>
> current windows locale, and in this case conversion from utf8 to utf16 will<br>
> fail (character values are negative). So my question is whether this<br>
> function should do the conversion at all, maybe there are other places in<br>
> the code that can call it with utf8 input that is obtained from some windows<br>
> function? In this particular case, conversion should be done using the<br>
> current locale. I'd like to hear what you think?<br>
<br>
</div></div>This was an oversight on my part. I assumed the command line would be<br>
in utf8 for some reason. Clang internals currently assume utf8, so the<br>
correct fix is to convert the command line to utf8 first. I'll look<br>
into adding this.<br>
<font color="#888888"><br>
- Michael Spencer<br>
</font></div><br></div></div>
</div></div></div><br>