[Zlib-devel] zlib gzopen_w function added
Cosmin Truta
cosmin at cs.toronto.edu
Sun Mar 18 00:29:35 EDT 2012
On Sat, Mar 17, 2012 at 6:58 PM, Mark Adler <madler at madler.net> wrote:
> zlibbers,
>
> Anyway, back to the original question: can someone test gzopen_w()?
Hi, Mark,
I just tested it, and it failed. You used w_char instead of wchar_t.
Moreover, in order to use this type, you must include <stddef.h> or
<wchar.h>.
I saw the conversation on this thread, and here is my take on it:
wchar_t and UTF-16 are not the same thing. It just happens that
wchar_t is 16-bit wide on Windows, and it is used to implement UTF-16
strings, and it is 32-bit wide on Unix, and it doesn't really
implement anything there, because UTF-32 is uselessly wasteful. The C
standard library has functions to handle both narrow-char strings and
wide-char strings. In Unix, narrow-char strings are typically used to
support UTF-8; in Windows, wide-char strings are typically used to
support UTF-16.
In the C standard library, functions handling narrow-char strings vs.
wide-char strings are clearly distinguished by their names, and zlib
should do the same. There shouldn't be any macro trickery to handle
this important interface detail. Windows does it differently, but
that's because they rely on the well-known (in the Windows world)
TCHAR abstraction. zlib doesn't have such an abstraction, and I don't
think it should introduce it.
Sincerely,
Cosmin
More information about the Zlib-devel
mailing list