<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE></TITLE>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.2963" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=051012408-10092006><FONT face=Arial
size=2>Frank,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=051012408-10092006><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=051012408-10092006><FONT face=Arial
size=2>I'm still interested to see what you think of the previous email, but i
did one test:</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=051012408-10092006><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=051012408-10092006><FONT face=Arial size=2>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.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=051012408-10092006><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=051012408-10092006><FONT face=Arial
size=2>Apparently, as the documentation for VSIFOpenL says, "</FONT><FONT
face=Arial size=2>the FILE * returned by this function is not really
a </FONT><FONT face=Arial size=2>standard C library FILE *, and cannot be
used with any functions other</FONT><FONT face=Arial size=2> than the VSI*L
family of functions." The converse appears true as well, you cannot use
regular FILE* with the VSI family of functions.</FONT></SPAN></DIV>
<DIV><SPAN class=051012408-10092006><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=051012408-10092006><FONT face=Arial size=2>Hence, it seems our
uptions are limited to the following:</FONT></SPAN></DIV>
<DIV><SPAN class=051012408-10092006><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=051012408-10092006><FONT face=Arial size=2>1. Provide a second
entry point for each GDAL function taking a (const char *filename), which takes
a (const wchar_t *filename).</FONT></SPAN></DIV>
<DIV><SPAN class=051012408-10092006><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=051012408-10092006><FONT face=Arial size=2>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 </FONT><FONT face=Arial
size=2>VSIFOpenL or similar, we would need code like this:</FONT></SPAN></DIV>
<DIV><SPAN class=051012408-10092006><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=051012408-10092006></SPAN><SPAN class=051012408-10092006><FONT
face=Arial size=2>FILE *VSIFOpenL( const char * pszFilename,
...)</FONT></SPAN></DIV>
<DIV><SPAN class=051012408-10092006><FONT face=Arial
size=2>{</FONT></SPAN></DIV>
<DIV><SPAN class=051012408-10092006><FONT face=Arial size=2>#if
WIN32</FONT></SPAN></DIV>
<DIV><SPAN class=051012408-10092006><FONT face=Arial size=2>
(convert pszFilename from utf-8 to wide string)</FONT></SPAN></DIV>
<DIV><SPAN class=051012408-10092006><FONT face=Arial size=2>
use _wfopen(wide string);</FONT></SPAN></DIV>
<DIV><SPAN class=051012408-10092006><FONT face=Arial size=2>#elif
__DARWIN_OSX__</FONT></SPAN></DIV>
<DIV><SPAN class=051012408-10092006> <FONT face=Arial
size=2>(proceed normally, it already expects utf-8)</FONT></SPAN></DIV>
<DIV><SPAN class=051012408-10092006><FONT face=Arial
size=2>#else</FONT></SPAN></DIV>
<DIV><SPAN class=051012408-10092006><FONT face=Arial size=2>
// some other flavor of Unix</FONT></SPAN></DIV>
<DIV><SPAN class=051012408-10092006> <FONT face=Arial
size=2>(convert pszFilename from utf-8 to wide string to local code page,
using ANSI wctombs())</FONT></SPAN></DIV>
<DIV><SPAN class=051012408-10092006> <FONT face=Arial
size=2>use fopen(local string);</FONT></SPAN></DIV>
<DIV><SPAN class=051012408-10092006></SPAN><SPAN class=051012408-10092006><FONT
face=Arial size=2>#endif</FONT></SPAN></DIV>
<DIV><SPAN class=051012408-10092006><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=051012408-10092006><FONT face=Arial size=2>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.</FONT></SPAN></DIV>
<DIV><SPAN class=051012408-10092006><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=051012408-10092006><FONT face=Arial size=2>Thoughts? I
can help do the implementation work, as i am now feeling fairly well grounded in
cross-platform charset issues.</FONT></SPAN></DIV>
<DIV><SPAN class=051012408-10092006><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=051012408-10092006><FONT face=Arial
size=2>Thanks,</FONT></SPAN></DIV>
<DIV><SPAN class=051012408-10092006><FONT face=Arial
size=2>Ben</FONT></SPAN><SPAN class=051012408-10092006></DIV></SPAN>
<DIV dir=ltr align=left><FONT face=Arial size=2></FONT><FONT face=Arial
size=2></FONT><BR></DIV>
<BLOCKQUOTE dir=ltr
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> Ben Discoe<BR><B>Sent:</B>
Saturday, September 09, 2006 2:32 PM<BR><B>To:</B>
gdal-dev@lists.maptools.org<BR><B>Subject:</B> RE: [Gdal-dev] Wide-character
filenames with GDAL file IO?<BR></FONT><BR></DIV>
<DIV></DIV><!-- Converted from text/plain format -->
<P><FONT face=Arial size=2>> > Then i could pass the fd into GDAL, if it
had a way of accepting it.<BR>><BR>> There is no support for this in
GDAL.<BR><BR>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?</FONT></P></BLOCKQUOTE></BODY></HTML>