CentOS7 unzip中文乱码

在CentOS7中,通过unzip命令解压包含中文目录的zip文件时出现乱码。尝试使用`unzip -O utf-8`和`unzip -O gbk`指定字符集,最终通过`unzip -O gbk`成功解决了中文乱码问题,正确解压出含有中文名称的文件和目录。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

正常解压

unzip 10、UML和电子商城(完整).zip

▒[root@corigin Android开发黑马28期]# unzip 10、UML和电子商城(完整).zip Archive:
10、UML和电子商城(完整).zip creating: 10бвUML║═╡ч╫╙╔╠│╟ги═ъ╒√гй/ creating:
10бвUML║═╡ч╫╙╔╠│╟ги═ъ╒√гй/day1/ inflating:
10бвUML║═╡ч╫╙╔╠│╟ги═ъ╒√гй/day1/1бв╧ю─┐┐к╖в╕┼╩Ў.avi

ll查看目录发现有一个乱码的目录

▒[root@corigin Android]# ll drwxr-xr-x. 3 root root 18 4月 28 19:55
10бвUML║═╡ч╫╙╔╠│╟ги═ъ╒√гй

查看unzip命令帮助

▒[root@corigin Android开发黑马28期]#unzip UnZip 6.00 of 20 April 2009, by
Info-ZIP. Maintained by C. Spieler. Send bug reports using
http://www.info-zip.org/zip-bug.html; see README for details.

Usage: unzip [-Z] [-opts[modifiers]] file[.zip] [list] [-x xlist] [-d
exdir] Default action is to extract files in list, except those in
xlist, to exdir; file[.zip] may be a wildcard. -Z => ZipInfo mode
(“unzip -Z” for usage).

-p extract files to pipe, no messages -l list files (short format)
-f freshen existing files, create none -t test compressed archive data
-u update files, create if necessary -z display archive comment only
-v list verbosely/show version info -T timestamp archive to latest
-x exclude files that follow (in xlist) -d extract files into exdir modifiers:
-n never overwrite existing files -q quiet mode (-qq => quieter)
-o overwrite files WITHOUT prompting -a auto-convert any text files
-j junk paths (do not make directories) -aa treat ALL files as text
-U use escapes for all non-ASCII Unicode -UU ignore any Unicode fields
-C match filenames case-insensitively -L make (some) names lowercase
-X restore UID/GID info -V retain VMS version numbers
-K keep setuid/setgid/tacky permissions -M pipe through “more” pager
-O CHARSET specify a character encoding for DOS, Windows and OS/2 archives
-I CHARSET specify a character encoding for UNIX and other archives

See “unzip -hh” or unzip.txt for more help. Examples: unzip data1 -x
joe => extract all files except joe from zipfile data1.zip unzip -p
foo | more => send contents of foo.zip via pipe into program more

发现-I,-O可以指定字符集,先试试utf-8

unzip -O utf-8 10、UML和电子商城(完整).zip

▒[root@corigin Android]# unzip -O utf-8 10、UML和电子商城(完整).zip Archive:
10、UML和电子商城(完整).zip creating: 10??UML???????????????/ creating:
10??UML???????????????/day1/ inflating:
10??UML???????????????/day1/1?????????????.avi

还是乱码,继续尝试gbk

`unzip -O gbk 10、UML和电子商城(完整).zip`

▒[root@corigin Android]# unzip -O gbk 10、UML和电子商城(完整).zip Archive:
10、UML和电子商城(完整).zip creating: 10、UML和电子商城(完整)/ creating:
10、UML和电子商城(完整)/day1/ inflating: 10、UML和电子商城(完整)/day1/1、项目开发概述.avi

这回中文字符终于正常了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值