UNZIP 文件名编码 - zzzz~~~'s Blog
UNZIP 文件名编码
zzzz~~~
posted @ 2013年1月28日 11:33
in Linux
, 2632 阅读
UNZIP 文件名编码
Translate: | Yugang LIU <liuyug@gmail.com> |
---|---|
Original: | http://blogs.gnome.org/happyaron/2010/09/03/workaround-of-file-name-problem-while-unzip-handling-cjk-encodings/ |
Unzip 5.x 拥有 -O 选项去阐述文件名编码,但在 6.0 中默认使用 Unicode,并且这个选项被删除了,使用 UTF-8 编码的 CJK 用户需要正确解压 ZIP 文档,下面是一个解决办法。
- 安装 p7zip 和 convmv
- 执行
env LANG=C 7za x zip_file.zip convmv -f gbk -t utf-8 --notest -r your_zip_folder
unzip 不能正确转换文件名编码,7zip 可以,然后用 convmv 转换成 UTF-8 编码。
下面是一个脚本
#! /bin/sh LANG=C /usr/bin/7z x -y "$1" | sed -n 's/^Extracting //p' | sed '1!G;h;$!d' | xargs convmv -f gbk -t utf8 --notest >/dev/null 2>/dev/null
保存为 unzip.sh,然后运行
sh unzip.sh zip_file.zip
这个动作就像是 unzip 所做的一样,只是额外做了文件名编码转换,convmv 会自动探测文件名编码。如果文件名编码不是 GBK,请用您的编码替换它。
2022年10月14日 17:12
I appreciate the help. I haven't had many enquiries about this topic recently. I'm going to stand by your side!
2022年10月21日 17:35
Thanks for sharing this information. I really like your blog post very much. You have really shared a informative and interesting blog post with people.
2022年11月09日 10:31
A new and special idea.
2022年11月24日 17:20
I am grateful that you shared this information with me.
2022年12月13日 11:29
I am grateful that you shared this knowledge with me. I truly enjoy the article that you made on your site a lot. People have been treated to a post that is both instructive and entertaining thanks to your contribution.
2022年12月27日 16:04
Your generosity in imparting this information to me is greatly appreciated. A lot of thanks for the wonderful material you posted on your blog. Thanks to your contribution, readers have access to a piece that serves dual purposes of educating and entertaining its audience.
2023年2月16日 10:23
Import photos and videos from Camera Roll. And Compress photos into ZIP file. including password protected.
2023年3月01日 09:05
A new and special idea.