【发布时间】:2012-05-10 07:17:29
【问题描述】:
在将 Ant 从 1.6 升级到 1.8.3 版本后,使用 Ant 构建的 Windows .dll 的信息资源已损坏。
之前此值已正确保存到版本信息资源中:
product.copyright=\u00a9 Copyright 20xx-20xx yyyyyyyyyy \u2122(因此 (c) 和 TM 符号已正确显示)。
升级 Ant 后默认编码已更改为预期的 UTF-8,但目前版权字符串如下所示:
© Copyright 20xx-20xx yyyyyy ™
这不是控制台问题 - 我检查了十六进制编辑器和文件属性对话框 - 两者都显示不正确。
查看文件的hexdump 我看到发生了以下(显然不正确)映射
\u00a9 -> 0x00c2 0x00a9
\u2122 -> 0x00e2 0x201e 0x00a2
这里的问题是 Ant 将 UTF-8 字节(不是 Unicode 字符串)编码为 16 位字符,并将其写入 version-info。
虽然这看起来像是 ant 中的一个错误,但我想问是否有人设法找到解决此问题或类似问题的任何方法。
以下是脚本中的一些 sn-ps: 项目属性文件:
...
product.copyright=(c) Copyright 2005-2012 Clarabridge
....
build.xml 中包含的文件:
<versioninfo id="current-version" if="is-windows"
fileversion="${product.version}"
productversion="${product.version}"
compatibilityversion="1"
legalcopyright="${product.copyright}"
companyname="${product.company}"
filedescription="${ant.project.name}"
productname="${ant.project.name}"
/>
...
<cc objdir="${target.dir}/${target.platform}/obj"
outfile="${target.dir}/${target.platform}/${ant.project.name}"
subsystem="other"
failonerror="true"
incremental="false"
outtype="shared"
runtime="dynamic"
>
<versioninfo refid="current-version" />
<compiler refid="compiler-shared-${target.platform}" />
<compiler refid="rc-compiler" />
<linker extends="linker-${target.platform}">
<libset dir="${target.dir}/${target.platform}/lib" libs="${lib.list}" />
</linker>
<fileset dir="${src.dir}" casesensitive="false">
<include name="*.cpp"/>
</fileset>
</cc>
【问题讨论】:
-
您是否尝试使用 ant -Dfile.encoding=utf8 启动 ant,也许您的控制台编码已关闭?
-
这个参数对我来说是默认包含的;我也没有看控制台输出,我看的是 dll 二进制文件和 Windows 文件属性
-
好的 :) 所以你有一个创建这些 dll 的 ant 任务(也许将它添加到问题中)?
-
@Fahrenheit2539 您应该发布脚本(使用资源的 sn-p)
-
不知道有什么帮助,但发布了一些相关的文章