首页 » 网站推广 » restorephp乱码技巧_Linux运用unzip解压文件名乱码的解决方法与思路请收藏好

restorephp乱码技巧_Linux运用unzip解压文件名乱码的解决方法与思路请收藏好

访客 2024-12-16 0

扫一扫用手机浏览

文章目录 [+]

如需学习视频,请在微信搜索公众号“智传网优”直接开始自助视频学习

1. 序言

restorephp乱码技巧_Linux运用unzip解压文件名乱码的解决方法与思路请收藏好

本文紧张讲解如何办理zip文件在解压时碰着的文件名乱码。

restorephp乱码技巧_Linux运用unzip解压文件名乱码的解决方法与思路请收藏好
(图片来自网络侵删)

请看以例子:

oucanrong@zcwyou:~/下载$ ll HCIE.zip

-rw-rw-r-- 1 oucanrong oucanrong 25659559 1月 24 15:03 HCIE-RS3.0ppt.zip

我们的目标是解压华为HCIE3.0的课件:HCIE-RS3.0ppt.zip

unzip不加参数解压:

oucanrong@zcwyou:~/下载$ unzip HCIE-RS3.0ppt.zip

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选项

oucanrong@zcwyou:~/下载$ unzip --help

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编码解压文件名。

oucanrong@zcwyou:~/下载$ unzip -O GBK HCIE-RS3.0ppt.zip

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编码解压文件名

oucanrong@zcwyou:~/下载$ unzip -O GB18030 HCIE-RS3.0ppt.zip

指定GB18030编码解压文件名

同样可以精确解码文件名。

也可以利用GB2312字符集。

oucanrong@zcwyou:~/下载$ unzip -O GB2312 HCIE-RS3.0ppt.zip

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

点击理解更多,快速查看更多的技能文章列表。

相关文章

php常量率低技巧_PHP 常量详解教程

PHP 常量常量是单个值的标识符(名称)。在脚本中无法改变该值。有效的常量名以字符或下划线开头(常量名称前面没有 $ 符号)。注释...

网站推广 2024-12-19 阅读1 评论0