[LLVMdev] request for windows unicode support

Török Edwin edwintorok at gmail.com
Fri Nov 26 06:38:26 PST 2010


On Fri, 26 Nov 2010 09:28:17 -0500
Michael Spencer <bigcheesegs at gmail.com> wrote:

> On Fri, Nov 26, 2010 at 4:00 AM, Jochen Wilhelmy
> <j.wilhelmy at arcor.de> wrote:
> > No, this post was prompted since I switched to boost::filesystem
> > version 3 in my own code and llvm/clang 2.8
> > was the only lib with no unicode support on windows.
> > Will your code be api compatible to boost::filesystem?
> 
> No. boost::filesystem makes extensive use of exceptions, which LLVM is
> compiled without, and it does a lot of string allocation and copying.
> 
> > The reason for this
> > is that maybe boost::filesystem
> > will become part of the standard and it is possible to imbue() a
> > locale on boost::filesystem.
> > While this feature is not needed on unix/macos it gives you global
> > control whether you want to use ansi or
> > unicode on windows.
> > If you implement your own code with always utf-8 this may break
> > compatibility with windows ansi
> > encoding if you don't take care and why reinvent the wheel? maybe
> > you could even copy/paste the
> > boost implementation and use the #ifdef HAVE_BOOST approach.
> >
> > -Jochen
> 
> The conversion only has to be written once. And while I do like the
> way boost::filesystem handles locale issues, the API is not suited for
> LLVM for the above reasons. However, if you have a better design than
> what I proposed, I'd love to see it. I'm not that familiar with
> dealing with Unicode under Windows.

Can't you just store filenames as UTF8 (like you do on Linux), and
convert UTF8 to widechar just when calling the windows APIs?
Same for converting back directory listings as such, you get widechar,
and convert back to UTF8.
All you would need to do is implement that conversion in System/Win32,
I think MultiByteToWideChar supports UTF8, doesn't it?

Best regards,
--Edwin



More information about the llvm-dev mailing list