> Thanks.
> Hi,
>
[quoted text clipped - 24 lines]
>
> the encoding format is UTF-8.
Your code seems to be contradicting this claim. It seems to be encoding
in Sun's special custom encoding (which is similar to, but distinct from,
UTF-16).
- Oliver
>>Hi,
>>
[quoted text clipped - 17 lines]
>>
>>"
I think you have just re-invented the wheel. Your code above converts a
String to a UTF-16 coded byte array. Your code above is equivalent to:
public byte[] toByteArray(String s)
{
return s.getBytes("UTF-16");
}
Hence the question arises: Did you really want to decode the String to a
UTF-16 coded byte array?
>>But this isn't doing the conversion properly. For example, for the €
>>(euro) symbol, it converts to some other unreadable symbol. Also, same
>>is the case for square brackets. Any idea why this' so? What's wrong
>>with the above code?
>
> the encoding format is UTF-8.
Which encoding format is UTF-8? The one you get, or the one you want?
May be you simply want:
public byte[] toByteArray(String s)
{
return s.getBytes("UTF-8");
}

Signature
Thomas