unzip 中文文件名乱码(压缩包解压文件名乱码)
请关注本头条号,每天坚持更新原创干货技术文章。如需学习视频,请在微信搜索公众号“智传网优”直接开始自助视频学习1. 前言本文主要讲解如何解决zip文件在解压时遇到的文件名乱码。请关注本头条号,每天坚持更新原创干货技术文章。如需学习视频,请在微信搜索公众号“智传网优”直接开始自助视频学习1. 前言本文主要讲解如何解决zip文件在解压时遇到的文件名乱码。请看以例子:oucanrong@zcwyou:~
请关注本头条号,每天坚持更新原创干货技术文章。如需学习视频,请在微信搜索公众号“智传网优”直接开始自助视频学习1. 前言本文主要讲解如何解决zip文件在解压时遇到的文件名乱码。
请关注本头条号,每天坚持更新原创干货技术文章。 如需学习视频,请在微信搜索公众号“智传网优”直接开始自助视频学习 1. 前言 本文主要讲解如何解决zip文件在解压时遇到的文件名乱码。 请看以例子: -rw-rw-r-- 1 oucanrong oucanrong 25659559 1月 24 15:03 HCIE-RS3.0ppt.zip 我们的目标是解压华为HCIE3.0的课件:HCIE-RS3.0ppt.zip unzip不加参数解压: Archive: HCIE-RS3.0ppt.zip creating: 01 PPT/ inflating: 01 PPT/HCRSE101-LAN╝╝╩ї.pptx inflating: 01 PPT/HCRSE102-WAN╝╝╩ї.pptx inflating: 01 PPT/HCRSE103-IPv6╗∙┤б.pptx inflating: 01 PPT/HCRSE104-OSPF╦л╒╗╘н└э.pptx inflating: 01 PPT/HCRSE105-ISIS╦л╒╗╘н└э.pptx inflating: 01 PPT/HCRSE106-BGP╦л╒╗╘н└эBasic.pptx inflating: 01 PPT/HCRSE107-BGP╦л╒╗╘н└эAdvance&Internet╔ш╝╞.pptx inflating: 01 PPT/HCRSE108-┬╖╙╔Import&Control.pptx inflating: 01 PPT/HCRSE109-MLD╘н└э.pptx inflating: 01 PPT/HCRSE110-PIM╦л╒╗╘н└э.pptx inflating: 01 PPT/HCRSE111-MPLS BGP VPN┐ч╙Є.pptx inflating: 01 PPT/HCRSE112-Security╝╝╩ї.pptx inflating: 01 PPT/HCRSE113-HA&═°╣▄.pptx inflating: 01 PPT/HCRSE114-QoS╘н└э.pptx inflating: 01 PPT/HCRSE115-SDN VXLAN╘н└э.pptx inflating: 01 PPT/HCRSE116-BGP EVPN╘н└э.pptx inflating: 01 PPT/HCRSE117-═°┬ч╔ш╝╞╙ы▓·╞╖╜щ╔▄.pptx inflating: 01 PPT/HCRSE118-╣╩╒╧░╕└¤╖╓╬Ў.pptx 不指定编码解压可能会引起乱码 结果是文件名全部乱码。 2. 查看unzip选项 UnZip 6.00 of 20 April 2009, by Debian. Original by Info-ZIP. 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 unzip -fo foo ReadMe => quietly replace existing ReadMe if archive file newer 找到-O选项,指定由DOS或者Windows编码的字符集 3. unzip解压时使用选项-O 选项-O用于指定DOS/Windows编码的字符集 使用GBK编码解压文件名。 Archive: HCIE-RS3.0ppt.zip inflating: 01 PPT/HCRSE101-LAN技术.pptx inflating: 01 PPT/HCRSE102-WAN技术.pptx inflating: 01 PPT/HCRSE103-IPv6基础.pptx inflating: 01 PPT/HCRSE104-OSPF双栈原理.pptx inflating: 01 PPT/HCRSE105-ISIS双栈原理.pptx inflating: 01 PPT/HCRSE106-BGP双栈原理Basic.pptx inflating: 01 PPT/HCRSE107-BGP双栈原理Advance&Internet设计.pptx inflating: 01 PPT/HCRSE108-路由Import&Control.pptx inflating: 01 PPT/HCRSE109-MLD原理.pptx inflating: 01 PPT/HCRSE110-PIM双栈原理.pptx inflating: 01 PPT/HCRSE111-MPLS BGP VPN跨域.pptx inflating: 01 PPT/HCRSE112-Security技术.pptx inflating: 01 PPT/HCRSE113-HA&网管.pptx inflating: 01 PPT/HCRSE114-QoS原理.pptx inflating: 01 PPT/HCRSE115-SDN VXLAN原理.pptx inflating: 01 PPT/HCRSE116-BGP EVPN原理.pptx inflating: 01 PPT/HCRSE117-网络设计与产品介绍.pptx inflating: 01 PPT/HCRSE118-故障案例分析.pptx 成功看到中文文件名。 使用GB18030编码解压文件名 指定GB18030编码解压文件名 同样可以正确解码文件名。 也可以使用GB2312字符集。 4. 关于中文字符集 早期的计算机使用7位的ASCII编码,为了处理汉字,程序员设计了用于简体中文的GB2312和用于繁体中文的big5。 4.1 GB2312字符集简介 GB2312(1980年):16位字符集,收录有6763个简体汉字,682个符号,共7445个字符; 优点:适用于简体中文环境,属于中国国家标准,通行于大陆,新加坡等地也使用此编码; 缺点:不兼容繁体中文,其汉字集合过少。 4.2 GBK字符集简介 GBK(1995年):16位字符集,收录有21003个汉字,883个符号,共21886个字符; 优点:适用于简繁中文共存的环境,为简体Windows所使用(代码页cp936),向下完全兼容gb2312,向上支持 ISO-10646 国际标准 ;所有字符都可以一对一映射到unicode2.0上; 缺点:不属于官方标准,和big5之间需要转换;很多搜索引擎都不能很好地支持GBK汉字。 4.3 GB18030字符集简介 GB18030(2000年):32位字符集;收录了27484个汉字,同时收录了藏文、蒙文、维吾尔文等主要的少数民族文字。 优点:可以收录所有你能想到的文字和符号,属于中国最新的国家标准; 缺点:目前支持它的软件较少。 4.4 补充Tips 现在的PC平台必须支持GB18030,对嵌入式产品暂不作要求。所以手机、MP3一般只支持GB2312。 从ASCII、GB2312、GBK到GB18030,这些编码方法是向下兼容的,即同一个字符在这些方案中总是有相同的编码,后面的标准支持更多的字符。在这些编码中,英文和中文可以统一地处理。区分中文编码的方法是高字节的最高位不为0。GB2312、GBK到GB18030都属于双字节字符集 (DBCS)。 GB18030是中国所有非手持/嵌入式计算机系统的强制实施标准。 本文已同步至博客站,尊重原创,转载时请在正文中附带以下链接: https://www.linuxrumen.com/rmxx/750.html 点击了解更多,快速查看更多的技术文章列表。oucanrong@zcwyou:~/下载$ ll HCIE*.zip
oucanrong@zcwyou:~/下载$ unzip HCIE-RS3.0ppt.zip
oucanrong@zcwyou:~/下载$ unzip --help
oucanrong@zcwyou:~/下载$ unzip -O GBK HCIE-RS3.0ppt.zip
oucanrong@zcwyou:~/下载$ unzip -O GB18030 HCIE-RS3.0ppt.zip
oucanrong@zcwyou:~/下载$ unzip -O GB2312 HCIE-RS3.0ppt.zip