[Gdal-dev] Wide-character filenames with GDAL file IO?

Ben Discoe ben at vterrain.org
Sun Sep 10 04:42:30 EDT 2006


Frank,
 
I'm still interested to see what you think of the previous email, but i did
one test:
 
I split CSLLoad into two methods:  the first takes a (const char *)
filename, the other takes a (FILE *).  The first just calls VSIFOpenL and
calls the second.  That opens the possibility of the user to pass their own
(FILE *) into the second.  However, it doesn't work.
 
Apparently, as the documentation for VSIFOpenL says, "the FILE * returned by
this function is not really a standard C library FILE *, and cannot be used
with any functions other than the VSI*L family of functions."  The converse
appears true as well, you cannot use regular FILE* with the VSI family of
functions.
 
Hence, it seems our uptions are limited to the following:
 
1. Provide a second entry point for each GDAL function taking a (const char
*filename), which takes a (const wchar_t *filename).
 
2. Leave the entry points the same, but declare that all non-ASCII filenames
passed to GDAL must be UTF-8.  This would have no effect on existing code
using ASCII filename, and no effect on existing code on OSX.  Inside
VSIFOpenL or similar, we would need code like this:
 
FILE *VSIFOpenL( const char * pszFilename, ...)
{
#if WIN32
    (convert pszFilename from utf-8 to wide string)
    use _wfopen(wide string);
#elif __DARWIN_OSX__
    (proceed normally, it already expects utf-8)
#else
    // some other flavor of Unix
    (convert pszFilename from utf-8 to wide string to local code page, using
ANSI wctombs())
    use fopen(local string);
#endif
 
3. Do the above, but make the methods which take UTF-8 into a separate set
of entry points.  That makes it 100% sure not to break anyone's existing
code, which might be currently passing in non-ASCII characters.
 
Thoughts?  I can help do the implementation work, as i am now feeling fairly
well grounded in cross-platform charset issues.
 
Thanks,
Ben



  _____  

From: Ben Discoe
Sent: Saturday, September 09, 2006 2:32 PM
To: gdal-dev at lists.maptools.org
Subject: RE: [Gdal-dev] Wide-character filenames with GDAL file IO?



> > Then i could pass the fd into GDAL, if it had a way of accepting it.
>
> There is no support for this in GDAL.

That might be a (relatively) painless solution then - for a the few places
in GDAL that take a (const char *) filename, a second entry point that take
a (FILE *).  I will explore this option, but you may already understand the
ramifications better?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20060909/55c407e4/attachment.html


More information about the Gdal-dev mailing list