cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: Curl and unicode file:// URLs on windows

From: David Byron <dbyron_at_dbyron.com>
Date: Tue, 11 May 2010 14:30:14 -0700

> On Tuesday, May 11th, 2010 Daniel Stenberg wrote:
>
> On Tue, 11 May 2010, jonas echterhoff wrote:
>
> > I tend to avoid windows myself when I can, but I found
> > other code on the web, which seems to handle it by
> > converting UTF-8 to UTF-16, and then using the result
> > with _wopen(). That is assuming that the file URL is
> > defined to be in UTF8 format (which makes sense, imo,
> > and is at least consistent with the mac, I don't know
> > how other Unixes handle Unicode file names).
> >
> > It is a Microsoft run-time library function, so I'd
> > assume that it should be available to all compilers on
> > windows. According to
> >
> > http://msdn.microsoft.com/en-us/library/z0kc8e3z(VS.80).aspx
> >
> > , it has been added in Windows NT 4.0 / Windows 2000.
>
> There's also a fopen_s() that might work.

At the risk of upsetting things, I'd like to suggest using CreateFileW
(http://msdn.microsoft.com/en-us/library/aa363858%28VS.85%29.aspx). The
bonus here is that not only can you support non-ascii characters, but you
also can support long filenames (more info on those here:
http://msdn.microsoft.com/en-us/library/aa365247%28VS.85%29.aspx). It may
also be nice to have something that's in kernel32.dll and not in msvcr*.dll.

-DB

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-05-11