ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 7765] New: - replace task does not accept encoding
Date Fri, 05 Apr 2002 14:14:50 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7765>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7765

replace task does not accept encoding

           Summary: replace task does not accept encoding
           Product: Ant
           Version: 1.4.1
          Platform: All
        OS/Version: Solaris
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Core tasks
        AssignedTo: ant-dev@jakarta.apache.org
        ReportedBy: sander@x-hive.com


The replace task does not take an encoding attribute. This is important, as now 
replace will open the file in the system default encoding, and also write it 
that way, which means character information may get lost.

We created a variation on your replace-task where you can specify an optional 
encoding attribute. Code changed for this in Replace.java:
Introduced 
  private String encoding = null;
Setter
    public void setEncoding(String encoding) {
        this.encoding = encoding;
    }
And changed opening of streams at line 294:
  BufferedReader br;
  BufferedWriter bw;
  if (this.encoding == null) {
    br = new BufferedReader(new FileReader(src));
    bw = new BufferedWriter(new FileWriter(temp));
  } else {
    //System.out.println("Using encoding: " + this.encoding);
    br = new BufferedReader(new InputStreamReader(new FileInputStream(src), 
encoding));
    bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(temp), 
encoding));
  }

No idea whether this also applies to other tasks.

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message