使用zlib的和UNI美元的Windows C $ C文件路径 [英] Using zlib with Unicode file paths on Windows

查看:135
本文介绍了使用zlib的和UNI美元的Windows C $ C文件路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用zlib的阅读gzip的COM pressed文件。
然后你使用打开一个文件

I'm reading gzip compressed files using zlib. Then you open a file using

gzFile gzopen(const char *filepath, const char *mode);

你是如何处理那些在Windows存储为常量为wchar_t * 的Uni code文件路径?

How do you handle Unicode file paths that are stored as const wchar_t* on Windows?

在类UNIX平台上你可以转换的文件路径为UTF-8并调用gzopen()
但不会在Windows上运行。

On UNIX-like platforms you can just convert the file path to UTF-8 and call gzopen(), but that will not work on Windows.

推荐答案

下一个版本的zlib将包括此功能,其中 _WIN32 已经#defined:

The next version of zlib will include this function where _WIN32 is #defined:

gzFile gzopen_w(常量为wchar_t *路径,字符*模式);

它的工作原理完全一样 gzopen(),除了它使用 _wopen()而不是的open()

It works exactly like gzopen(), except it uses _wopen() instead of open().

我故意不重复 _wfopen(),并作为一个结果,我并没有把它叫做 _wgzopen(),以避免与函数的参数可能的混淆。因此,名称 gzopen_w()。这也避免了使用C-保留名称空间。

I purposely did not duplicate the second argument of _wfopen(), and as a result I did not call it _wgzopen() to avoid possible confusion with that function's arguments. Hence the name gzopen_w(). That also avoids the use of the C-reserved name space.

这篇关于使用zlib的和UNI美元的Windows C $ C文件路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆