-
Notifications
You must be signed in to change notification settings - Fork 0
Home
A set of tools for re-encoding text files in a new character encoding. The tools include a Java API and an Apache Ant task.
Re-encoding of files can be performed with an Ant task, which is included in the source code. The Ant task allows you to convert one or more files using a fileset. You simply specify the original encoding of the files, the encoding you want to convert to and the output directory. The encoding of the original files will be converted and then placed in the output directory, using the same file names as the originals.
First you need to obtain the Jar file with the Ant task from ???. Then install the Jar in a place where Ant will be able to find it. See the Ant docs on optional tasks for details.
In your Ant script you will have to define a task using a taskdef tag. After defining this task, which you can name whatever you wish, you can use it in your Ant script just like any other task. See the sample script below for an example.
<?xml version="1.0" encoding="UTF-8"?>
<project name="sample" default="default">
<taskdef name="ReEncode"
classname="org.charencodingconv.ant.CharEncodingConverter"
classpath="charencodingconv-0.1.jar"
/>
<target name="default">
<ReEncode inputEncoding="US-ASCII" outputEncoding="ISO-8859-1" todir="out">
<fileset dir="samples" includes=".txt"/>
</ReEncode>
</target>
</project>
In the Ant script above, the task was defined and given the name ReEncode. The ReEncode task was then used to re-encode all of the *.txt files in the samples directory.