zoukankan      html  css  js  c++  java
  • 解决mac压缩包在windows下解压乱码问题。

    我用的360压缩,然后出现乱码。

    解决方法:可以下载最新的winrar,5以上的版本。

    原因从别的地方查到的:备份一下。

    详情可以参看这里:感谢作者。

    http://frank19900731.github.io/blog/2015/02/11/jie-jue-mac-xia-zip-ya-suo-wen-jian-zai-windows-xia-xian-shi-luan-ma-de-wen-ti/ 

    知乎上关于这个问题的 解答 是

    Mac OS X 系统自带的压缩程序对 zip 文件名用 UTF-8 编码,但 zip 文件头中没有声明 PKZIP 高版本增加的 Unicode 位。Windows 会认为文件名是 ANSI 编码,结果显示乱码。

    经过简单的资料阅读和测试,我大概验证了下这种解释。

    用 locale 命令查看我的 MBP 系统编码,确实是 UTF-8。

    系统编码
    1 2 3 4 5 6 7 8 9 
    $> locale LANG="zh_CN.UTF-8" LC_COLLATE="zh_CN.UTF-8" LC_CTYPE="zh_CN.UTF-8" LC_MESSAGES="zh_CN.UTF-8" LC_MONETARY="zh_CN.UTF-8" LC_NUMERIC="zh_CN.UTF-8" LC_TIME="zh_CN.UTF-8" LC_ALL= 

    关于 ANSI 编码 ,在中文 Windows 系统中可能是 GBK 编码,而在其他语言的 Windows 系统又可能是别的。可以想见,Mac 下打出的压缩包在不同语言的 Windows 下会乱得各具特色

    当然,并不是所有解压缩软件都会一股脑地用 ANSI 编码进行解压。有的解压软件能够自动识别(文件名)编码并不确定的时候请使用者选择,比如 Mac 下的 The Unarchiver。根据我在中文 Win7 下的测试,不同的解压缩软件对压缩文件的默认“理解”也是不同的,快压会解出乱码,而 7zip、Winrar 则可以正确解码。

    一种直观的想法是,可以对文件名给出统一编码格式或者将编码写进压缩文件供解压缩程序读取。然而,Zip files and Encoding – I hate you. 中提到

    The Zip spec does not seem to know that there are normalization models for UTF-8, when there are actually 4 (or more, because there is some non-standard ones too!). The Zip file gives no guidance as to how file names inside zip files are to be normalized.

    The Zip spec says that the only supported encodings are CP437 and UTF-8, but everyone has ignored that. Implementers just encode file names however they want (usually byte for byte as they are in the OS…

    很遗憾,Mac 自带的 zip 命令就属于最后一句中 Implementers。虽然我不是很清楚“文件头中没有声明 PKZIP 高版本增加的 Unicode 位”中的细节,不过后来通过比较发现,无乱码和有乱码的 zip 文件,以 16进制方式查看时,文件名中中文字符的编码是一样的不同之处确实在 zip 文件头

  • 相关阅读:
    LINUX的SSH下FTP到远程服务器Entering Passive Mode失败解决
    LINUX的SSH下FTP到远程服务器Entering Passive Mode失败解决
    LINUX的SSH下FTP到远程服务器Entering Passive Mode失败解决
    git rm简介
    git rm简介
    git rm简介
    linux rz -e
    新版住院电子病历首页 (2012年修订说明)
    DateEdit和TimeEdit用法
    ORA-22868: 具有 LOB 的表包含有位于不同表空间的段
  • 原文地址:https://www.cnblogs.com/hanyuxinting/p/5841456.html
Copyright © 2011-2022 走看看