ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christopher Taylor" <>
Subject Bug in the <copy> task, patch to follow
Date Sat, 23 Feb 2002 10:02:46 GMT

I tried submitting a bug to the bugzilla bug system, but it appears to be
down at the moment, so I sent email to general and I'm also sending the same

If you use the <copy> task with filtering turned on, and the file is a
different encoding type than the default decoding, the copy task will mangle
the destination file.

For example, I am using a Windows 2000 workstation with JDK 1.4 installed.
I am putting together a Japanese and English website, where the files are
all in UTF-8 format.  The default encoding (as seen with the following code:


FileReader reader = new FileReader("some file");
System.out.println (reader.getEncoding());

will be CP1252 (US-ASCII).  What the copy task needs is an additional
IMPLIED attribute that specifies the encoding for filtering tasks.  The code
in the class would need to be changed so
it could receive an encoding parameter as well.  Lines 220, 221 of would need to be replaced with:

FileInputStream fis = new FileInputStream (sourceFile);
FileOutputStream fos = new FileOutputStream (destFile);
InputStreamReader in = new InputStreamReader (fis, encoding);
OutputStreamWriter out = new OutputStreamWriter (fos, encoding);

This would fix the encoding problems with the filtering, as long as all
content encountered during the filtering process was UTF8 encoded (since
ASCII is subsumed by UTF8, this shouldn't be a problem for most people).


P.S. The patch contains changes to and in the same
patch file

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message