ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Greg Roodt" <>
Subject Re: Passing multi-byte strings from ANT using <sysproperty> task
Date Thu, 11 Dec 2008 11:40:46 GMT
Basically SK wants to pass a System Property into a Java programme executed
by Ant. The problem is, that he wants to set non-ASCII characters as the
System Property, which is a bit tricky.

I agree with you, we need a clearer understanding of what SK is trying to
achieve and perhaps BASE-64 or escape codes will be sufficient.


On Thu, Dec 11, 2008 at 11:12 AM, Mark Salter <>wrote:

> Shashidhar Kotta wrote:
> > Hi,
> >
> > I have tried with your ANT code but it is displaying ?m?n??? only.
> Your code is encoding the String it sees into UTF-8, this is likely the
> right output, but not what you expected?
> You need to think through what you are trying to do, but from this
> result, I would suggest that your code might be receiving the Unicode
> value correctly from Ant.  I would be surprised though.  To check you
> would need to print the string in a Unicode 'aware' way.
> To guide, we need to know what you intend to do with this string, but
> this is less of an Ant question and more a Java question.
> >
> > Here is the simple java code which I am using.
> >
> > OutputStreamWriter bos = new OutputStreamWriter(new
> FileOutputStream("D://testoutput.txt"),"UTF-8");
> > String username = System.getProperty("com.param1").trim();
> > bos.write(username);
> > bos.close();
> >
> > and here is the output from "testoutput.txt" file  -?m?nя??
> Your code is taking a String and encoding it in the file under UTF-8.
> UTF-8 does not have the characters you need so it tries to do it's best
> for you and 'fails'.
> It gives you a result, which you are retrieving from  a file, copying
> and pasting into an email.. This flow also involves a number of
> interpretations too.
> I don't see you have stated what you want to do with your Unicode value
> yet?  If you do want it to persist in a file encode in UTF-8 then you
> need to convert the Unicode bytes into a format that can be held in this
> encoding.  Perhaps 're-escaping' or BASE-64 encoding it.
> Personally I think you should also be specifying the value within the
> Ant xml in UTF-8, so you comply with the encoding statement at the top
> of the xml.  BASE-64 or escaped might do you.
> --
> Mark
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message