[Zlib-devel] zlib gzopen_w function added
Mark Adler
madler at madler.net
Sat Mar 17 11:58:00 EDT 2012
On Mar 17, 2012, at 1:20 AM, William A. Rowe Jr. wrote:
> We would be very happy if zlib API's spoke utf-8. Otherwise this
> is altogether a misguided effort.
Bill,
I will certainly defer to the judgement of the Windows experts here, since I don't use it. Let me discuss the rationale for the gzopen_w() function.
zlib's API's already do speak UTF-8 on everything except Windows. On Windows, the open() function, which is used by gzopen() does *not* accept UTF-8. So the zlib interface as it now stands does not permit passing files names using UTF-8 or UTF-16 on Windows, i.e. no foreign characters at all. So something needs to be done to support that.
The two choices as I understand it are: a) on Windows have gzopen() accept UTF-8 by converting the provided file name to UTF-16 and calling _wopen() instead of open(), or b) leave gzopen() alone and provide a new gzopen-like() function that accepts UTF-16 directly, calling _wopen(). I chose b) because it most closely matches the current interface in Windows which provides an fopen() and a _wfopen(), where the former accepts a byte-string that cannot be UTF-8, and the latter accepts a UTF-16 file name, and that it is the simplest, most direct approach that requires no conversions and uses the Windows native unicode character representation (UTF-16).
If I understand you correctly, you would strongly prefer option a).
Mark
More information about the Zlib-devel
mailing list