byte array to string conversion

Lars Andersen lars@rimfaxe.com
Fri Sep 12 23:02:00 GMT 2003


Tom Tromey wrote:

>>>>>>"Lars" == Lars Andersen <lars@rimfaxe.com> writes:
>>>>>>            
>>>>>>
>
>Lars> Substitute "iso-8859-1" with "UTF-8" and only Sun jdk works (at least
>Lars> for me)
>
>Are you sure it really works with the JDK?
>The byte buffer you're passing to the String constructor doesn't
>contain a valid UTF-8 sequence.
>
>Tom
>  
>

Yep.

And in the "UTF-8" case I noticed the following differences between JDK 
and GCJ :

JDK : allBytesString.length() = 256
GCJ : allBytesString.length() = 128

And the characters are offset by 128, so allBytesString.charAt(40) in 
GCJ would match allBytesString.charAt(168) in JDK

/Lars Andersen



More information about the Java mailing list