文件名中的 rubyzip 和 unicode 字符
我正在使用 rubyzip
gem 和 Zip::ZipOutputStream
类创建 zip 存档,并且遇到了 unicode 字母(西里尔字母)的问题 - 在存档中它们显示为问号,例如 <代码>???? ???? ??.doc。 rubyzip 支持 unicode 吗?
I am creating zip archive with rubyzip
gem and Zip::ZipOutputStream
class and have got a problem with unicode letters (cyrillic) - in archive they are presented as question marks like ????? ???? ??.doc
. Does rubyzip support unicode?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我查看了 rubyzip 方法,似乎 rubyzip 不能更改语言。它可能使用您计算机的默认代码页。您可以使用 chilkat zip 代替此示例,除非您有特定要求chilkat 无法解决这个问题。
I looked at rubyzip methods and it doesn't seem that rubyzip can change the language. It probably uses your computer's default code page. You could use chilkat zip instead as in this example unless you have specific requirements that cannot be addressed by chilkat.
您可以使用以下代码片段将 UTF-8 转换为 CP437 ,其中涵盖了一些 unicode 字符(只是很少)。 Windows 7 及更早版本假定文件名以 CP437 编码。
You can use the following snippet to convert UTF-8 to CP437 which cover some unicode chars (just a few). Windows 7 and older assume that filenames are encoded in CP437.
你可以直接运行 zip 。
注意具体报价。在 Ubuntu 上为我工作,处理西里尔文文件名,而 rubyzip 则生成具有不可读文件名的存档。
You may just run zip directly.
Notice specific quotes. Worked for me on Ubuntu for Cyrillic file names, while rubyzip was generating archive with non-readable file names.
这对我有用。在创建 Zip 文件之前设置此文件
我从 https://github.com/rubyzip 获得此文件/rubyzip#non-ascii-names
Here's what worked for me. Set this before creating the Zip file
I got this from https://github.com/rubyzip/rubyzip#non-ascii-names