View Full Version : BigIntiger toByteArray

01-28-2008, 02:05 AM
providing that s = BigIntiger ("60830453755921259750972507581")

String result = new String(s.toByteArray(), "UTF-8");

result becomes "\u0000čČ"

why is "\u0000" there, what does it mean ?

besides I'm unable to reproduce 60830453755921259750972507581 trying with:

String s = "čČ";
String s1 = new String(s.getBytes(),"UTF-8");
// or String s1 = new String(s.getBytes());
byte[] bytes = s.getBytes();
BigInteger m = new BigInteger(bytes);

Any thougt welcome.

01-28-2008, 05:22 AM
"\u0000" is a null terminator character. If you take the string "\u0000čČ" instead of "čČ" and convert that back to a BigInteger then you will see that you've recreated your original number.

I can't say exactly why it's there but if you look at the implementation for the String constructor that you're using you should be able to pin it down.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum