ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject DO NOT REPLY [Bug 47382] New: Encoding attribute of loadproperties does not function correctly
Date Wed, 17 Jun 2009 12:52:01 GMT

           Summary: Encoding attribute of loadproperties does not function
           Product: Ant
           Version: 1.6.5
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P3
         Component: Core tasks

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/">

However, on z/OS the file is checked out as EBCDIC
automatically by svn so I tried adding the encoding attribute to this task:

 <loadproperties srcfile="${basedir}/make/"

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:
------- You are receiving this mail because: -------
You are the assignee for the bug.

View raw message