从 Ant tar 任务打包的 .tar.gz 中提取包含非拉丁字符的文件名的编码 [英] Encoding of filenames containing non-latin characters while extracting from .tar.gz packed by Ant tar task

查看:18
本文介绍了从 Ant tar 任务打包的 .tar.gz 中提取包含非拉丁字符的文件名的编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Ant 构建 tar.gz 存档:

I'm building a tar.gz archive using Ant:

<tar destfile="${linux86.zip.file}" compression="gzip" longfile="gnu">
    <tarfileset dir="${work.dir}/data" dirmode="755" filemode="755"  
                prefix="${app.folder}/data"/>
</tar>

存档是在 Windows 上构建的.在 Ubuntu 12 上提取名称包含非拉丁(例如西里尔文)字符的文件后,名称已损坏.

Archive is built on Windows. After being extracted on Ubuntu 12 files with names containing non-latin (for example, cyrillic) characters have broken names.

有什么办法可以解决或解决这个问题吗?

Is there any way to fix or work around that?

推荐答案

我在 Ant 的开发者邮件列表 (2009 年 6 月 30 日2009 年 7 月 1 日)和 ASF Bugzilla(36851, 53811).这个问题是老生常谈了,主要是出于意识形态原因,它还没有得到解决,因为并非所有 untar 实现都支持这一点.

I have found some interesting information in Ant's developer mailing list (30 Jun 2009, 01 Jul 2009) and in ASF Bugzilla (36851, 53811). The problem is old and well-known, it has not been fixed mainly for ideological reasons because not all untar implementations support that.

Bugzilla 问题中提到的补丁已应用于修订版 1350857.tar 中的条目名称有一个带有编码名称的构造函数:

Patch mentioned in Bugzilla issue has been applied in revision 1350857. There is a constructor with name of encoding for entry name in tar:

public TarOutputStream(OutputStream os, String encoding) { ... }

但它从未在 Tar 任务中使用过.所以我在 Tar 任务中做了一个编码属性,从修改过的源重新构建 Ant 并使用 UTF-8 作为条目名称的编码.

But it is never used in Tar task though. So I made an encoding attribute in Tar task, rebuilt Ant from modified sources and used UTF-8 as encoding of entry names.

在 Ubuntu 11/12 和 Mandriva 下进行了提取测试.

Extraction tested under Ubuntu 11/12 and Mandriva.

这篇关于从 Ant tar 任务打包的 .tar.gz 中提取包含非拉丁字符的文件名的编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆