This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: byte array to string conversion
Tom Tromey wrote:
"Lars" == Lars Andersen <lars@rimfaxe.com> writes:
Lars> Just tried it with the latest 3.4 snapshot. Same thing.
I suspect your system's iconv(), or your locale setting, or both.
Try debugging the program with gdb. My theory is that the early
`test_str.getBytes()' call is returning bad results.
Tom
Well, if I replace toAsciiString with another implementation it works fine.
Like this :
public static final String toAsciiString(byte[] buffer, int startPos,
int length)
{
byte[] stringBytes = new byte[length];
int endIndex = startPos + length;
int pos = 0;
for (int i = startPos; i < endIndex; i++)
{
stringBytes[pos++] = buffer[i];
}
return new String(stringBytes);
}
But I guess you could be right on the locale thing, since I use both
english and danish settings.
Investigating now ....
/Lars Andersen