Boost logo

Boost Users :

Subject: Re: [Boost-users] [filesystem] wpath and fopen() on windows
From: Paul (elegant_dice_at_[hidden])
Date: 2010-02-11 18:36:24


On 11 February 2010 06:19, OvermindDL1 <overminddl1_at_[hidden]> wrote:

> On Wed, Feb 10, 2010 at 7:21 AM, Paul <elegant_dice_at_[hidden]> wrote:
> > Hi,
> > What is the best way for me to use boost::filesystem::wpath with a 3rd
> party
> > C library that expects a const char* filename, on Windows?
> > On linux, its simple: my_file.to_external_string() but on windows that
> > gives me a wide-character string.
> > So far the only thing I can think of is to roll my own wstring --> UTF8
> > conversion function, but I'm not even sure that is correct (will fopen()
> > work with UTF-8 encoded filenames on windows?).
> > thanks,
>
> That is correct. On Windows XP and higher *all* file function use
> wide-character strings. Their are ascii versions of the same
> functions, but you can see the implementation and they just convert
> the string to a wide then call the normal function, hence having it
> wide in the first place saves you time. It seems pretty stupid to
> convert from wide to ascii just to have the system waste even more
> time converting from ascii back to wide. I do not think file
> functions will work with all UTF-8 though as UTF-8 support in the
> Windows kernel is... lacking...
>

This sounds like interacting with many C programs that open files could be a
big problem...

Take for example, zlib
http://zlib.net/manual.html#Gzip

fs::wpath my_path = whatever;

gzFile f = gzopen( my_path.NARROW(), "r" );

??

In zlib's case, I might be saved because I can call gzopen on a
file-descriptor, but there are other libraries (one of which I am using)
that will only accept a char* filename...

What do I do?

thanks,
Paul



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net