<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>unzip &#8211; 张三太爷</title>
	<atom:link href="https://www.somedoc.net/tag/unzip/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.somedoc.net</link>
	<description>看前面，黑洞洞</description>
	<lastBuildDate>Thu, 05 Mar 2020 03:12:21 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.1</generator>

<image>
	<url>https://www.somedoc.net/wp-content/uploads/2016/12/cropped-dandycheung-1-32x32.jpg</url>
	<title>unzip &#8211; 张三太爷</title>
	<link>https://www.somedoc.net</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>解决 unzip 命令解压 Windows 下生成的 zip 包时文件名乱码的问题</title>
		<link>https://www.somedoc.net/2020/02/29/%e8%a7%a3%e5%86%b3-unzip-%e5%91%bd%e4%bb%a4%e8%a7%a3%e5%8e%8b-windows-%e4%b8%8b%e7%94%9f%e6%88%90%e7%9a%84-zip-%e5%8c%85%e6%97%b6%e6%96%87%e4%bb%b6%e5%90%8d%e4%b9%b1%e7%a0%81%e7%9a%84%e9%97%ae/</link>
					<comments>https://www.somedoc.net/2020/02/29/%e8%a7%a3%e5%86%b3-unzip-%e5%91%bd%e4%bb%a4%e8%a7%a3%e5%8e%8b-windows-%e4%b8%8b%e7%94%9f%e6%88%90%e7%9a%84-zip-%e5%8c%85%e6%97%b6%e6%96%87%e4%bb%b6%e5%90%8d%e4%b9%b1%e7%a0%81%e7%9a%84%e9%97%ae/#comments</comments>
		
		<dc:creator><![CDATA[张三太爷]]></dc:creator>
		<pubDate>Sat, 29 Feb 2020 08:02:19 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[备忘录]]></category>
		<category><![CDATA[技术]]></category>
		<category><![CDATA[电脑]]></category>
		<category><![CDATA[软件]]></category>
		<category><![CDATA[问题解决]]></category>
		<category><![CDATA[unzip]]></category>
		<guid isPermaLink="false">http://www.somedoc.net/?p=4357</guid>

					<description><![CDATA[收到一个压缩包，用 unzip 解压，发现原来的中文文件名全 <a href="https://www.somedoc.net/2020/02/29/%e8%a7%a3%e5%86%b3-unzip-%e5%91%bd%e4%bb%a4%e8%a7%a3%e5%8e%8b-windows-%e4%b8%8b%e7%94%9f%e6%88%90%e7%9a%84-zip-%e5%8c%85%e6%97%b6%e6%96%87%e4%bb%b6%e5%90%8d%e4%b9%b1%e7%a0%81%e7%9a%84%e9%97%ae/" class="more-link">[&#8230;]</a>]]></description>
										<content:encoded><![CDATA[<p>收到一个压缩包，用 unzip 解压，发现原来的中文文件名全是乱码。</p>
<p>查找解决办法，发现网络上有不止一个人提到可以给 <code>unzip</code> 命令指定 <code>-O CP936</code> 选项来纠正这一问题，但实测无果，也许是我 Debian 下没有支持 936 代码页需要的文件或者库？看起来并不像，因为连有人说的 <code>unzip --help</code> 输出信息中对此参数有一点说明的痕迹也没发现。还有人说可以设定环境变量云云，一看也是此方法的变种，不足采用。</p>
<p>有人提示可以使用 <code>unar</code> 命令，于是熟练地 apt 安装之，是好使的。看安装时的依赖组件，这个工具倒像是 Objective-C 写的。</p>
<p>后来想到如果只是文件名的编码问题的话，应该可以在处理每个文件的时候想办法纠正过来，开始还想是不是有 shell 脚本可以，后来找到一份 python 代码（参见 https://blog.csdn.net/gatieme/article/details/44807105，其中还有可以更改源码自己编译的部分，也可以参看 https://www.cnblogs.com/JesseTsou/p/10488435.html，未予实践），也就认了，略作修订如下，实测管用。</p>
<p></p><pre class="crayon-plain-tag">#!/usr/bin/env python
# -*- coding: utf-8 -*-
# uzip.py

import os
import sys
import zipfile

print "File " + sys.argv[1] + " unzipping..."

file = zipfile.ZipFile(sys.argv[1], "r");

for name in file.namelist():
    utf8name = name.decode('gbk')
    print "Extracting " + utf8name + "..."

    pathname = os.path.dirname(utf8name)
    if not os.path.exists(pathname) and pathname != "":
        os.makedirs(pathname)

    data = file.read(name)
    if not os.path.exists(utf8name):
        fo = open(utf8name, "w")
        fo.write(data)
        fo.close

file.close()

print "File " + sys.argv[1] + " unzipped."</pre><p> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.somedoc.net/2020/02/29/%e8%a7%a3%e5%86%b3-unzip-%e5%91%bd%e4%bb%a4%e8%a7%a3%e5%8e%8b-windows-%e4%b8%8b%e7%94%9f%e6%88%90%e7%9a%84-zip-%e5%8c%85%e6%97%b6%e6%96%87%e4%bb%b6%e5%90%8d%e4%b9%b1%e7%a0%81%e7%9a%84%e9%97%ae/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
