代码之家  ›  专栏  ›  技术社区  ›  Sunil Garg

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

  •  0
  • Sunil Garg  · 技术社区  · 7 年前

    我有一些js文件在 UTF-8 BOM 编码。我想将这些文件转换为 UTF-8 copy 蚂蚁的任务

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

    现在当我打开一个文件 在记事本++中,它以 ANSI 格式,但这也附加了  文件开头的字符。

    this 我如何解决这个问题?

    1 回复  |  直到 7 年前
        1
  •  1
  •   Sunil Garg    7 年前

    将这些文件编码为 UTF-8 我用过 replaceregexp \xEF\xBB\xBF 使用空字符串。

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