https://issues.apache.org/bugzilla/show_bug.cgi?id=47382
Summary: Encoding attribute of loadproperties does not function
correctly
Product: Ant
Version: 1.6.5
Platform: PC
OS/Version: Windows XP
Status: NEW
Severity: normal
Priority: P3
Component: Core tasks
AssignedTo: [email protected]
ReportedBy: [email protected]
When running the Apache Harmony build on a z/OS machine I hit a problem loading
one of our properties files. We do something along the lines of:
<loadproperties srcfile="${basedir}/make/depends.properties">
...
</loadproperties>
However, on z/OS the depends.properties file is checked out as EBCDIC
automatically by svn so I tried adding the encoding attribute to this task:
<loadproperties srcfile="${basedir}/make/depends.properties.ascii"
encoding="ISO-8859-1">
...
</loadproperties>
Unfortunately this also failed to load the relevant properties. I had a dig
into the loadproperties task code and see that when an encoding is specified it
does something along the lines of:
instream = new InputStreamReader(bis, encoding);
String text = crh.readFully(instream);
ByteArrayInputStream tis = new ByteArrayInputStream(text.getBytes(encoding));
We end up failing to read the file because the specified encoding should *not*
be passed to getBytes(). What happens at the moment is:
- The first 2 lines read the properties file from the specified encoding
converting it to the default Java encoding (UTF-16?).
- The third line converts the text into a byte array specifying the encoding
to be converted from. However, "text" has already been converted into the
default Java encoding, and when getBytes() converts it from EBCDIC->UTF-16
again we end up with garbage.
The second getBytes() call should specify the encoding we expect it to convert
_from_, which is the Java default encoding here.
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.