在 ANT 中将文件转换为没有 BOM 的 UTF-8

Converting files to UTF-8 without BOM in ANT

我有一些 UTF-8 BOM 编码的 js 文件。我想使用 ant 将这些文件转换为 UTF-8 编码。为此我使用了 copy ant 任务

<copy todir="./custom_plugins" overwrite="true" outputencoding="UTF-8">
    <fileset dir="../plugins" />
</copy>

现在,当我在 notepad++ 中打开 UTF-8 BOM 中的文件时,它会以 ANSI 格式显示其编码,但这还会在文件开头附加  字符。

我什至尝试了 this,但没有用。 我该如何解决这个问题?

将这些文件编码为 UTF-8 后,我使用 replaceregexp ant 任务将 remove/replace BOM 字符 \xEF\xBB\xBF 与空字符串。

<replaceregexp match="\xEF\xBB\xBF" replace="" byline="true" encoding="UTF-8">
    <fileset dir="./custom_plugins">
        <include name="**/*.js"/>
    </fileset>
</replaceregexp>