Code Guru
Code Guru

Reputation: 15578

Converting files to UTF-8 without BOM in ANT

I have some js files that are in UTF-8 BOM encoding. I want to convert these files to UTF-8 encoding using ant. I used copy task of ant for this

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

Now when I open a file that was in UTF-8 BOM in notepad++ it shows its encoding in ANSI format but this also appends the  character at the beginning of the file.

Even i tried this, but not working. How can I solve this?

Upvotes: 0

Views: 1227

Answers (1)

Code Guru
Code Guru

Reputation: 15578

After encoding these files to UTF-8 I used replaceregexp ant task to remove/replace BOM character \xEF\xBB\xBF with empty string.

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

Upvotes: 1

Related Questions